Class BindingContext
Context for binding an IBehavior to an ISimulation.
Implements
Inherited Members
Namespace: SpiceSharp.Entities
Assembly: SpiceSharp.dll
Syntax
[BindingContextFor(typeof(Entity))]
public class BindingContext : IBindingContext
Remarks
This is an additional layer that allows to shield entities, simulations, etc. from the behavior that is being created. This makes sure that behaviors are only using the data that matters.
Constructors
BindingContext(IEntity, ISimulation, IBehaviorContainer)
Initializes a new instance of the BindingContext class.
Declaration
public BindingContext(IEntity entity, ISimulation simulation, IBehaviorContainer behaviors)
Parameters
| Type | Name | Description |
|---|---|---|
| IEntity | entity | The entity creating the behavior. |
| ISimulation | simulation | The simulation for which a behavior is created. |
| IBehaviorContainer | behaviors | The behavior container. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
Properties
Behaviors
Gets the previously created behaviors.
Declaration
public IBehaviorContainer Behaviors { get; }
Property Value
| Type | Description |
|---|---|
| IBehaviorContainer | The previously created behaviors. |
Entity
Gets the entity that provides the parameters without exposing the entity itself.
Declaration
protected IEntity Entity { get; }
Property Value
| Type | Description |
|---|---|
| IEntity | The entity. |
Simulation
Gets the simulation to bind to without exposing the simulation itself.
Declaration
protected ISimulation Simulation { get; }
Property Value
| Type | Description |
|---|---|
| ISimulation | The simulation. |
Methods
GetParameterSet<P>()
Gets the parameter set of the specified type.
Declaration
public P GetParameterSet<P>() where P : IParameterSet, ICloneable<P>
Returns
| Type | Description |
|---|---|
| P | The parameter set. |
Type Parameters
| Name | Description |
|---|---|
| P | The parameter set type. |
GetSimulationParameterSet<P>()
Gets a simulation parameter set of the specified type.
Declaration
public P GetSimulationParameterSet<P>() where P : IParameterSet, ICloneable<P>
Returns
| Type | Description |
|---|---|
| P | The parameter set. |
Type Parameters
| Name | Description |
|---|---|
| P | The parameter set type. |
GetState<S>()
Gets a simulation state.
Declaration
public S GetState<S>() where S : ISimulationState
Returns
| Type | Description |
|---|---|
| S | The simulation state. |
Type Parameters
| Name | Description |
|---|---|
| S | The type of simulation state. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown if the state is not defined on the simulation. |
TryGetParameterSet<P>(out P)
Tries to get the parameter set of the specified type.
Declaration
public bool TryGetParameterSet<P>(out P value) where P : IParameterSet, ICloneable<P>
Parameters
| Type | Name | Description |
|---|---|---|
| P | value | The parameter set. |
Returns
| Type | Description |
|---|---|
| bool |
|
Type Parameters
| Name | Description |
|---|---|
| P | The parameter set type. |
TryGetSimulationParameterSet<P>(out P)
Tries to get a simulation parameter set of the specified type.
Declaration
public bool TryGetSimulationParameterSet<P>(out P value) where P : IParameterSet, ICloneable<P>
Parameters
| Type | Name | Description |
|---|---|---|
| P | value | The value. |
Returns
| Type | Description |
|---|---|
| bool | The parameter set. |
Type Parameters
| Name | Description |
|---|---|
| P | The parameter set type. |
TryGetState<S>(out S)
Tries to get a simulation state.
Declaration
public bool TryGetState<S>(out S state) where S : ISimulationState
Parameters
| Type | Name | Description |
|---|---|---|
| S | state | The simulation state. |
Returns
| Type | Description |
|---|---|
| bool |
|
Type Parameters
| Name | Description |
|---|---|
| S | The type of simulation state. |
UsesState<S>()
Declaration
public bool UsesState<S>() where S : ISimulationState
Returns
| Type | Description |
|---|---|
| bool |
Type Parameters
| Name | Description |
|---|---|
| S |