C# Class Castle.MicroKernel.Resolvers.DefaultDependencyResolver

Inheritance: IDependencyResolver
Exibir arquivo Open project: 7digital/Castle.Windsor

Public Methods

Method Description
AddSubResolver ( ISubDependencyResolver subResolver ) : void

Registers a sub resolver instance

CanResolve ( CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency ) : bool

Returns true if the resolver is able to satisfy the specified dependency.

Initialize ( IKernel kernel, DependencyDelegate dependencyDelegate ) : void

Initializes this instance with the specified dependency delegate.

RemoveSubResolver ( ISubDependencyResolver subResolver ) : void

Unregisters a sub resolver instance previously registered

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

Try to resolve the dependency by checking the parameters in the model or checking the Kernel for the requested service.

The dependency resolver has the following precedence order: The dependency is checked within the CreationContext The dependency is checked within the IHandler instance for the component The dependency is checked within the registered ISubDependencyResolver s Finally the resolver tries the normal flow which is using the configuration or other component to satisfy the dependency

Protected Methods

Method Description
CanResolveParameterDependency ( ComponentModel model, DependencyModel dependency ) : bool
CanResolveServiceDependency ( CreationContext context, ComponentModel model, DependencyModel dependency ) : bool
ExtractComponentKey ( String keyValue, String name ) : String

Extracts the component name from the a ref strings which is ${something}

ObtainParameterModelMatchingDependency ( DependencyModel dependency, ComponentModel model ) : ParameterModel
RebuildContextForParameter ( CreationContext current, Type parameterType ) : CreationContext

This method rebuild the context for the parameter type. Naive implementation.

ResolveParameterDependency ( CreationContext context, ComponentModel model, DependencyModel dependency ) : object
ResolveServiceDependency ( CreationContext context, ComponentModel model, DependencyModel dependency ) : object

Private Methods

Method Description
GetParameterModelByType ( Type type, ComponentModel model ) : ParameterModel
HasComponentInValidState ( CreationContext context, Type service ) : bool
HasComponentInValidState ( string key ) : bool
IsHandlerInValidState ( IHandler handler ) : bool
ObtainParameterModelByKey ( DependencyModel dependency, ComponentModel model ) : ParameterModel
ObtainParameterModelByType ( DependencyModel dependency, ComponentModel model ) : ParameterModel
RaiseDependencyResolving ( ComponentModel model, DependencyModel dependency, object value ) : void
TryGetHandlerFromKernel ( DependencyModel dependency, CreationContext context ) : IHandler

Method Details

AddSubResolver() public method

Registers a sub resolver instance
public AddSubResolver ( ISubDependencyResolver subResolver ) : void
subResolver ISubDependencyResolver The subresolver instance
return void

CanResolve() public method

Returns true if the resolver is able to satisfy the specified dependency.
public CanResolve ( CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency ) : bool
context Castle.MicroKernel.Context.CreationContext Creation context, which is a resolver itself
contextHandlerResolver ISubDependencyResolver Parent resolver
model Castle.Core.ComponentModel Model of the component that is requesting the dependency
dependency Castle.Core.DependencyModel The dependency model
return bool

CanResolveParameterDependency() protected method

protected CanResolveParameterDependency ( ComponentModel model, DependencyModel dependency ) : bool
model Castle.Core.ComponentModel
dependency Castle.Core.DependencyModel
return bool

CanResolveServiceDependency() protected method

protected CanResolveServiceDependency ( CreationContext context, ComponentModel model, DependencyModel dependency ) : bool
context Castle.MicroKernel.Context.CreationContext
model Castle.Core.ComponentModel
dependency Castle.Core.DependencyModel
return bool

ExtractComponentKey() protected method

Extracts the component name from the a ref strings which is ${something}
protected ExtractComponentKey ( String keyValue, String name ) : String
keyValue String
name String
return String

Initialize() public method

Initializes this instance with the specified dependency delegate.
public Initialize ( IKernel kernel, DependencyDelegate dependencyDelegate ) : void
kernel IKernel kernel
dependencyDelegate DependencyDelegate The dependency delegate.
return void

ObtainParameterModelMatchingDependency() protected method

protected ObtainParameterModelMatchingDependency ( DependencyModel dependency, ComponentModel model ) : ParameterModel
dependency Castle.Core.DependencyModel
model Castle.Core.ComponentModel
return Castle.Core.ParameterModel

RebuildContextForParameter() protected method

This method rebuild the context for the parameter type. Naive implementation.
protected RebuildContextForParameter ( CreationContext current, Type parameterType ) : CreationContext
current Castle.MicroKernel.Context.CreationContext
parameterType System.Type
return Castle.MicroKernel.Context.CreationContext

RemoveSubResolver() public method

Unregisters a sub resolver instance previously registered
public RemoveSubResolver ( ISubDependencyResolver subResolver ) : void
subResolver ISubDependencyResolver The subresolver instance
return void

Resolve() public method

Try to resolve the dependency by checking the parameters in the model or checking the Kernel for the requested service.
The dependency resolver has the following precedence order: The dependency is checked within the CreationContext The dependency is checked within the IHandler instance for the component The dependency is checked within the registered ISubDependencyResolver s Finally the resolver tries the normal flow which is using the configuration or other component to satisfy the dependency
public Resolve ( CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency ) : object
context Castle.MicroKernel.Context.CreationContext Creation context, which is a resolver itself
contextHandlerResolver ISubDependencyResolver Parent resolver
model Castle.Core.ComponentModel Model of the component that is requesting the dependency
dependency Castle.Core.DependencyModel The dependency model
return object

ResolveParameterDependency() protected method

protected ResolveParameterDependency ( CreationContext context, ComponentModel model, DependencyModel dependency ) : object
context Castle.MicroKernel.Context.CreationContext
model Castle.Core.ComponentModel
dependency Castle.Core.DependencyModel
return object

ResolveServiceDependency() protected method

protected ResolveServiceDependency ( CreationContext context, ComponentModel model, DependencyModel dependency ) : object
context Castle.MicroKernel.Context.CreationContext
model Castle.Core.ComponentModel
dependency Castle.Core.DependencyModel
return object