Class DI.Resolver<TContext>
The dependency injection container that is used by entities to create behaviors.
Inheritance
Inherited Members
Namespace: SpiceSharp.Entities.DependencyInjection
Assembly: SpiceSharp.dll
Syntax
protected class Resolver<TContext> : IBehaviorResolver<TContext>, IBehaviorResolver where TContext : IBindingContext
Type Parameters
| Name | Description |
|---|---|
| TContext |
Constructors
Resolver()
Declaration
public Resolver()
Methods
Clear()
Clears any strategies.
Declaration
public void Clear()
RegisterAfter<TBehavior>(Func<TContext, IBehavior>)
Registers a behavior factory for the specified target behavior after any previously defined factories.
Declaration
public IBehaviorResolver<TContext> RegisterAfter<TBehavior>(Func<TContext, IBehavior> factory)
where TBehavior : IBehavior
Parameters
| Type | Name | Description |
|---|---|---|
| System.Func<TContext, IBehavior> | factory | The factory. |
Returns
| Type | Description |
|---|---|
| IBehaviorResolver<TContext> | The IBehaviorResolver<TContext> for chaining. |
Type Parameters
| Name | Description |
|---|---|
| TBehavior | The target behavior. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown if |
RegisterAfter<TBehavior, TBehaviorImpl>()
Registers a behavior factory for the specified target behavior after any previously defined factories.
Declaration
public IBehaviorResolver<TContext> RegisterAfter<TBehavior, TBehaviorImpl>()
where TBehavior : IBehavior where TBehaviorImpl : TBehavior, IBehavior
Returns
| Type | Description |
|---|---|
| IBehaviorResolver<TContext> | The IBehaviorResolver<TContext> for chaining. |
Type Parameters
| Name | Description |
|---|---|
| TBehavior | The target behavior. |
| TBehaviorImpl | The behavior implementation. |
RegisterBefore<TBehavior>(Func<TContext, IBehavior>)
Registers a behavior factory for the specified target behavior before any previously defined factories.
Declaration
public IBehaviorResolver<TContext> RegisterBefore<TBehavior>(Func<TContext, IBehavior> factory)
where TBehavior : IBehavior
Parameters
| Type | Name | Description |
|---|---|---|
| System.Func<TContext, IBehavior> | factory | The factory. |
Returns
| Type | Description |
|---|---|
| IBehaviorResolver<TContext> | The IBehaviorResolver<TContext> for chaining. |
Type Parameters
| Name | Description |
|---|---|
| TBehavior | The target behavior. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown if |
RegisterBefore<TBehavior, TBehaviorImpl>()
Registers a behavior factory for the specified target behavior before any previously defined factories.
Declaration
public IBehaviorResolver<TContext> RegisterBefore<TBehavior, TBehaviorImpl>()
where TBehavior : IBehavior where TBehaviorImpl : TBehavior, IBehavior
Returns
| Type | Description |
|---|---|
| IBehaviorResolver<TContext> | The IBehaviorResolver<TContext> for chaining. |
Type Parameters
| Name | Description |
|---|---|
| TBehavior | The target behavior. |
| TBehaviorImpl | The behavior implementation. |
Resolve(ISimulation, IBehaviorContainer, TContext)
Resolves behaviors in the container for the specified simulation and context.
Declaration
public void Resolve(ISimulation simulation, IBehaviorContainer container, TContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| ISimulation | simulation | The simulation. |
| IBehaviorContainer | container | The container. |
| TContext | context | The context. |
Resolve(ISimulation, IEntity, IBehaviorContainer)
Creates behaviors in the container for the specified simulation and entity.
Declaration
public void Resolve(ISimulation simulation, IEntity entity, IBehaviorContainer container)
Parameters
| Type | Name | Description |
|---|---|---|
| ISimulation | simulation | The simulation. |
| IEntity | entity | The entity. |
| IBehaviorContainer | container | The behavior container. |
Explicit Interface Implementations
IBehaviorResolver.RegisterAfter(Type, Type)
Registers a behavior factory for the specified target behavior after any previously defined factories.
Declaration
IBehaviorResolver IBehaviorResolver.RegisterAfter(Type behavior, Type behaviorImplementation)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | behavior | The behavior. |
| System.Type | behaviorImplementation | The behavior implementation. |
Returns
| Type | Description |
|---|---|
| IBehaviorResolver | The IBehaviorResolver for chaining. |
IBehaviorResolver.RegisterBefore(Type, Type)
Registers a behavior factory for the specified target behavior before any previously defined factories.
Declaration
IBehaviorResolver IBehaviorResolver.RegisterBefore(Type behavior, Type behaviorImplementation)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | behavior | The behavior. |
| System.Type | behaviorImplementation | The behavior implementation. |
Returns
| Type | Description |
|---|---|
| IBehaviorResolver | The IBehaviorResolver for chaining. |