2006/2007
Licence Apache 2.0
[Link]
Castle Igloo Basics
• Pre-require
• Concept
• Scopes
• PageFlow
• Configuration
• Controller
• View
• Exemple
[Link]
Concepts
An "MVC" framework for [Link]
• Manages Flow page
• Manages typed user context support
• Injection of Controller in UI element (Page, User
control, MasterPage)
• Transparent integration in [Link]
• Testable controller
• Multiple scope component (Session, request,
page, application, custom, conversation [In
progress])
[Link]
Pre-Require
• It’s only .NET 2.0
• You need to install the
Web Application Projects which comes
back once again to default in VS 2005
Service Pack 1.
• [Link] dll
[Link]
Scopes
Page 1 Page X Page X Page X Page Page Page
Request Scope
Conversation Scope
Page Scope
Session Scope
Application Scope
Scope Web context
Singleton Scope Thread Scope Transient Scope Custom Scope
[Link]
Scopes
• Application Scope : Scopes a single component definition to the lifecycle of an [Link]
application.
• Conversation Scope : Scope conversation provides fine grain control over the session
scope so that "concurrent conversations" can occur.
• Page Scope : Scopes a single component model to the lifecycle of a aspx page.
• Request Scope : Scopes a single component model to the lifecycle of a single HTTP
request;
• Session Scope : Scopes a single component model to the lifecycle of a HTTP Session.
• Singleton Scope : Scopes a single component model to a single object instance per Castle
IoC container.
• Transient Scope : Scopes a single component model to any number of object instances.
• Thread Scope : Scopes a single component model to the lifecycle of a thread
[Link]
Scope notion
• Component wiring (dependency injection) is performed when an IOC
managed component are instantiated, which means that, a component in a
wide scope (such as singleton) cannot have a reference to a component in a
narrow scope (the request/session ..., for examples).
• To fixes this problem you must always created and injected a proxy
component for every reference of a narrow scoped component.
This proxy component exposes the same public interface as the scoped
component but it will be able to determine the real, target object from the
relevant (request/session...) scope and delegate method calls onto this real
object. This proxy will be created by Igloo.
• Requirement for proxy component in a scope are made when configuring
component (next slide)
• All scope implement the IScope interface and you can implement your own
scope.
Such custom scope are referenced as others components in the
configuration file.
[Link]
Component scoping
• Via XML configuration (scope attribute on
component tag)
• Via .NET Attribute on component class
[Link]
View
• UI element must derive from
[Link],
[Link]. MasterPage,
[Link]. UserControl
• Support Controller injection
• Support context user injection
[Link]
Controller
• Must derive from base class :
[Link]
• Are Request scope by default (via
heritage)
• Method on controller must be virtual to
allow interception.
[Link]
State user management
• Provides safe, intuitive user state
management
• [Inject(ScopeName)] attribute specifies
that a state value should be
[Link]
Inject Attribute
• Name : The scope variable name. Defaults to
the name of the annotated field or getter
method.(Not required)
• Scope :Explicitly specify the scope to search,
instead of searching all scopes.(Not required)
• Create : Specifies that a object should be
instantiated if the scope variable is null.
[Link]
Navigation
• The NavigationState contains data for
processing navigation.
• NavigationState can be accessed on Controller
• SkipNavigation attribute specifies that a
controller method must not declench a
navigation to another view.
[Link]
Page Flow
• Action is alimented from the
‘commandName’ attribute of UI control
(Button..) or can been via code
[Link]
Page Flow Navigation
• Navigation flow are automatically done
after a call of a controller’s method via an
interceptor and so each controller method
must be declare as Virtual.
[Link]
Exemple : IOC Configuration
[Link]
Exemple : Login Page
IOC
injection
Login Page
[Link]
Example : Login Controller
IOC
injection
User state
management
Navigation
management
+
Flash
message
[Link]
Exemple : 2 page
nd
User state
injection
IOC
injection
[Link]
Example : Patient Controller
IOC
injection
User state
injection
User state
injection
Navigation
management
User state
management
[Link]