Show / Hide Table of Contents

Class BehaviorContainer

A dictionary of Behavior. Only on instance of each type is allowed.

Inheritance
object
InterfaceTypeSet<IBehavior>
BehaviorContainer
Implements
IBehaviorContainer
ITypeSet<IBehavior>
ICollection<IBehavior>
IEnumerable<IBehavior>
IEnumerable
IParameterSetCollection
IParameterSet
Inherited Members
InterfaceTypeSet<IBehavior>.TypeNotFound
InterfaceTypeSet<IBehavior>.Count
InterfaceTypeSet<IBehavior>.IsReadOnly
InterfaceTypeSet<IBehavior>.Add(IBehavior)
InterfaceTypeSet<IBehavior>.Clear()
InterfaceTypeSet<IBehavior>.Contains(IBehavior)
InterfaceTypeSet<IBehavior>.ContainsType<TResult>()
InterfaceTypeSet<IBehavior>.ContainsType(Type)
InterfaceTypeSet<IBehavior>.CopyTo(IBehavior[], int)
InterfaceTypeSet<IBehavior>.GetValue<TResult>()
InterfaceTypeSet<IBehavior>.Remove(IBehavior)
InterfaceTypeSet<IBehavior>.TryGetValue<TResult>(out TResult)
InterfaceTypeSet<IBehavior>.GetEnumerator()
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: SpiceSharp.Behaviors
Assembly: SpiceSharp.dll
Syntax
public class BehaviorContainer : InterfaceTypeSet<IBehavior>, IBehaviorContainer, ITypeSet<IBehavior>, ICollection<IBehavior>, IEnumerable<IBehavior>, IEnumerable, IParameterSetCollection, IParameterSet

Constructors

BehaviorContainer(string)

Initializes a new instance of the BehaviorContainer class.

Declaration
public BehaviorContainer(string source)
Parameters
Type Name Description
string source

The entity name that will provide the behaviors.

Exceptions
Type Condition
ArgumentNullException

Thrown if source is null.

Properties

Name

Gets the name.

Declaration
public string Name { get; }
Property Value
Type Description
string

The name of the behavior container.

Remarks

This is typically the name of the entity that creates the behaviors in this container.

ParameterSets

Gets all the parameter sets of this instance.

Declaration
public IEnumerable<IParameterSet> ParameterSets { get; }
Property Value
Type Description
IEnumerable<IParameterSet>

The parameter sets.

Methods

Build<TContext>(ISimulation, TContext)

Declaration
public IBehaviorContainerBuilder<TContext> Build<TContext>(ISimulation simulation, TContext context) where TContext : IBindingContext
Parameters
Type Name Description
ISimulation simulation
TContext context
Returns
Type Description
IBehaviorContainerBuilder<TContext>
Type Parameters
Name Description
TContext

CreateParameterSetter<P>(string)

Creates an action that can set the parameter of the specified type and with the specified name.

Declaration
public Action<P> CreateParameterSetter<P>(string name)
Parameters
Type Name Description
string name

The name of the parameter.

Returns
Type Description
Action<P>

An action that can set the parameter value, or null if the parameter could not be found.

Type Parameters
Name Description
P

The parameter value type.

Exceptions
Type Condition
ArgumentNullException

Thrown if name is null.

CreatePropertyGetter<P>(string)

Creates a function that can get the value of a property of the specified type and with the specified name.

Declaration
public Func<P> CreatePropertyGetter<P>(string name)
Parameters
Type Name Description
string name

The name of the property.

Returns
Type Description
Func<P>

A function that can get the property value, or null if the property could not be found.

Type Parameters
Name Description
P

The property value type.

Exceptions
Type Condition
ArgumentNullException

Thrown if name is null.

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.

Exceptions
Type Condition
TypeNotFoundException

Thrown if the parameter set could not be found.

GetProperty<P>(string)

Gets the value of a property of the specified type and with the specified name.

Declaration
public P GetProperty<P>(string name)
Parameters
Type Name Description
string name

The name of the property.

Returns
Type Description
P

The value of the property.

Type Parameters
Name Description
P

The property value type.

Exceptions
Type Condition
ArgumentNullException

Thrown if name is null.

ParameterNotFoundException

Thrown if a parameter by the specified name could not be found.

SetParameter<P>(string, P)

Sets a parameter in the parameter set of the specified type and with the specified name.

Declaration
public void SetParameter<P>(string name, P value)
Parameters
Type Name Description
string name

The name of the parameter.

P value

The value that the parameter should be set to.

Type Parameters
Name Description
P

The parameter value type.

Exceptions
Type Condition
ArgumentNullException

Thrown if name is null.

ParameterNotFoundException

Thrown if a parameter by the specified name could not be found.

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

true if the parameter set was found; otherwise, false.

Type Parameters
Name Description
P

The parameter set type.

TryGetProperty<P>(string, out P)

Tries to get the value of a property of the specified type and with the specified name.

Declaration
public bool TryGetProperty<P>(string name, out P value)
Parameters
Type Name Description
string name

The name of the property.

P value

The value of the property if the property was found.

Returns
Type Description
bool

true if the property was found and returned; otherwise, false.

Type Parameters
Name Description
P

The property value type.

Exceptions
Type Condition
ArgumentNullException

Thrown if name is null.

TrySetParameter<P>(string, P)

Tries to set a parameter in the parameter set of the specified type and with the specified name.

Declaration
public bool TrySetParameter<P>(string name, P value)
Parameters
Type Name Description
string name

The name of the parameter.

P value

The value that the parameter should be set to.

Returns
Type Description
bool

true if a parameter was found and set succesfully; otherwise, false.

Type Parameters
Name Description
P

The parameter value type.

Exceptions
Type Condition
ArgumentNullException

Thrown if name is null.

Implements

IBehaviorContainer
ITypeSet<V>
ICollection<T>
IEnumerable<T>
IEnumerable
IParameterSetCollection
IParameterSet

Extension Methods

Utility.ThrowIfNull<T>(T, string)
Documentation.ParameterValues<T>(IParameterSet, bool)
Documentation.Parameters(IParameterSet)
Documentation.ParameterValues<T>(IParameterSetCollection, bool)
Documentation.Parameters(IParameterSetCollection)
Utility.ThrowIfEmpty<T>(IEnumerable<T>, string)

See Also

IBehaviorContainer
IParameterSetCollection
In this article
Back to top Generated by DocFX