C# Class Castle.MicroKernel.Handlers.AbstractHandler.AbstractHandler

Inheritance: System.MarshalByRefObject, IHandler, IExposeDependencyInfo, IDisposable
Mostra file Open project: 7digital/Castle.Windsor

Protected Properties

Property Type Description
lifestyleManager ILifestyleManager

Public Methods

Method Description
AddCustomDependencyValue ( object key, object value ) : void
CanResolve ( CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency ) : bool
Dispose ( ) : void
HasCustomParameter ( object key ) : bool
Init ( IKernel kernel ) : void

Saves the kernel instance, subscribes to IKernelEvents.AddedAsChildKernel event, creates the lifestyle manager instance and computes the handler state.

IsBeingResolvedInContext ( CreationContext context ) : bool
ObtainDependencyDetails ( IList dependenciesChecked ) : String

Returns human readable list of dependencies this handler is waiting for.

Release ( object instance ) : bool

disposes the component instance (or recycle it).

ReleaseCore ( object instance ) : bool

Should be implemented by derived classes: disposes the component instance (or recycle it)

RemoveCustomDependencyValue ( object key ) : void
Resolve ( CreationContext context ) : object

Returns an instance of the component this handler is responsible for

Resolve ( CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency ) : object
TryResolve ( CreationContext context ) : object

Protected Methods

Method Description
AbstractHandler ( ComponentModel model ) : System

Constructs and initializes the handler

AddDependency ( DependencyModel dependency ) : void

Invoked by EnsureDependenciesCanBeSatisfied in order to check if a dependency can be satisfied. If not, the handler is set to a 'waiting dependency' state.

This method registers the dependencies within the correct collection or dictionary and changes the handler state to HandlerState.WaitingDependency

CanSatisfyConstructor ( ConstructorCandidate constructor ) : bool
CanSatisfyDependency ( DependencyModel dependency ) : bool
CreateLifestyleManager ( IComponentActivator activator ) : ILifestyleManager

Creates an implementation of ILifestyleManager based on LifestyleType and invokes ILifestyleManager.Init to initialize the newly created manager.

DependencySatisfied ( bool &stateChanged ) : void

Invoked by the kernel when one of registered dependencies were satisfied by new components registered.

Handler for the event IKernelEvents.HandlerRegistered

EnsureDependenciesCanBeSatisfied ( IDependencyAwareActivator activator ) : void

Checks if the handler is able to, at very least, satisfy the dependencies for the constructor with less parameters

For each non*optional dependency, the implementation will invoke AddDependency

OnAddedAsChildKernel ( object sender, EventArgs e ) : void

Invoked when the container receives a parent container reference.

This method implementation checks whether the parent container is able to supply the dependencies for this handler.

Resolve ( CreationContext context, bool instanceRequired ) : object

Returns an instance of the component this handler is responsible for

ResolveCore ( CreationContext context, bool requiresDecommission, bool instanceRequired ) : object

Should be implemented by derived classes: returns an instance of the component this handler is responsible for

SetNewState ( HandlerState newState ) : void

Private Methods

Method Description
AddGraphDependency ( IHandler handler ) : void
DisconnectEvents ( ) : void
GetBestCandidatesByDependencyType ( IEnumerable candidates ) : List
GetCandidateConstructors ( ) : IEnumerable
GetSecuredDependencies ( ) : IEnumerable
HandlerStateChanged ( object source, EventArgs args ) : void

Handler for the event OnHandlerStateChanged

HasValidComponent ( String key, DependencyModel dependency ) : bool
HasValidComponent ( Type service, DependencyModel dependency ) : bool
HasValidComponentFromResolver ( DependencyModel dependency ) : bool
InitializeCustomDependencies ( ) : void
IsValidHandlerState ( IHandler handler ) : bool
RaiseHandlerStateChanged ( ) : void
SelectMostValuableCandidate ( IEnumerable candidates ) : ConstructorCandidate
SelectMostValuableCandidateByName ( IEnumerable candidates ) : ConstructorCandidate
Union ( ICollection firstset, ICollection secondset ) : DependencyModel[]

Method Details

AbstractHandler() protected method

Constructs and initializes the handler
protected AbstractHandler ( ComponentModel model ) : System
model Castle.Core.ComponentModel
return System

AddCustomDependencyValue() public method

public AddCustomDependencyValue ( object key, object value ) : void
key object
value object
return void

AddDependency() protected method

Invoked by EnsureDependenciesCanBeSatisfied in order to check if a dependency can be satisfied. If not, the handler is set to a 'waiting dependency' state.
This method registers the dependencies within the correct collection or dictionary and changes the handler state to HandlerState.WaitingDependency
protected AddDependency ( DependencyModel dependency ) : void
dependency Castle.Core.DependencyModel
return void

CanResolve() public method

public CanResolve ( CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency ) : bool
context Castle.MicroKernel.Context.CreationContext
contextHandlerResolver ISubDependencyResolver
model Castle.Core.ComponentModel
dependency Castle.Core.DependencyModel
return bool

CanSatisfyConstructor() protected method

protected CanSatisfyConstructor ( ConstructorCandidate constructor ) : bool
constructor Castle.Core.ConstructorCandidate
return bool

CanSatisfyDependency() protected method

protected CanSatisfyDependency ( DependencyModel dependency ) : bool
dependency Castle.Core.DependencyModel
return bool

CreateLifestyleManager() protected method

Creates an implementation of ILifestyleManager based on LifestyleType and invokes ILifestyleManager.Init to initialize the newly created manager.
protected CreateLifestyleManager ( IComponentActivator activator ) : ILifestyleManager
activator IComponentActivator
return ILifestyleManager

DependencySatisfied() protected method

Invoked by the kernel when one of registered dependencies were satisfied by new components registered.
Handler for the event IKernelEvents.HandlerRegistered
protected DependencySatisfied ( bool &stateChanged ) : void
stateChanged bool
return void

Dispose() public method

public Dispose ( ) : void
return void

EnsureDependenciesCanBeSatisfied() protected method

Checks if the handler is able to, at very least, satisfy the dependencies for the constructor with less parameters
For each non*optional dependency, the implementation will invoke AddDependency
protected EnsureDependenciesCanBeSatisfied ( IDependencyAwareActivator activator ) : void
activator IDependencyAwareActivator
return void

HasCustomParameter() public method

public HasCustomParameter ( object key ) : bool
key object
return bool

Init() public method

Saves the kernel instance, subscribes to IKernelEvents.AddedAsChildKernel event, creates the lifestyle manager instance and computes the handler state.
public Init ( IKernel kernel ) : void
kernel IKernel
return void

IsBeingResolvedInContext() public method

public IsBeingResolvedInContext ( CreationContext context ) : bool
context CreationContext
return bool

ObtainDependencyDetails() public method

Returns human readable list of dependencies this handler is waiting for.
public ObtainDependencyDetails ( IList dependenciesChecked ) : String
dependenciesChecked IList
return String

OnAddedAsChildKernel() protected method

Invoked when the container receives a parent container reference.
This method implementation checks whether the parent container is able to supply the dependencies for this handler.
protected OnAddedAsChildKernel ( object sender, EventArgs e ) : void
sender object
e EventArgs
return void

Release() public method

disposes the component instance (or recycle it).
public Release ( object instance ) : bool
instance object
return bool

ReleaseCore() public abstract method

Should be implemented by derived classes: disposes the component instance (or recycle it)
public abstract ReleaseCore ( object instance ) : bool
instance object
return bool

RemoveCustomDependencyValue() public method

public RemoveCustomDependencyValue ( object key ) : void
key object
return void

Resolve() public method

Returns an instance of the component this handler is responsible for
public Resolve ( CreationContext context ) : object
context CreationContext
return object

Resolve() public method

public Resolve ( CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency ) : object
context CreationContext
contextHandlerResolver ISubDependencyResolver
model ComponentModel
dependency DependencyModel
return object

Resolve() protected method

Returns an instance of the component this handler is responsible for
protected Resolve ( CreationContext context, bool instanceRequired ) : object
context CreationContext
instanceRequired bool when false, handler can not create valid instance and return null instead
return object

ResolveCore() protected abstract method

Should be implemented by derived classes: returns an instance of the component this handler is responsible for
protected abstract ResolveCore ( CreationContext context, bool requiresDecommission, bool instanceRequired ) : object
context CreationContext
requiresDecommission bool
instanceRequired bool When false, handler can not create valid instance and return null instead.
return object

SetNewState() protected method

protected SetNewState ( HandlerState newState ) : void
newState HandlerState
return void

TryResolve() public method

public TryResolve ( CreationContext context ) : object
context CreationContext
return object

Property Details

lifestyleManager protected_oe property

Lifestyle manager instance
protected ILifestyleManager lifestyleManager
return ILifestyleManager