Show / Hide Table of Contents

Class BehaviorContainerCollection

A pool of all behaviors. This class will keep track which behavior belongs to which entity. Only behaviors can be requested from the collection.

Inheritance
object
BehaviorContainerCollection
Implements
IBehaviorContainerCollection
IEnumerable<IBehaviorContainer>
IEnumerable
Inherited Members
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 BehaviorContainerCollection : IBehaviorContainerCollection, IEnumerable<IBehaviorContainer>, IEnumerable

Constructors

BehaviorContainerCollection()

Initializes a new instance of the BehaviorContainerCollection class.

Declaration
public BehaviorContainerCollection()

BehaviorContainerCollection(IEqualityComparer<string>)

Initializes a new instance of the BehaviorContainerCollection class.

Declaration
public BehaviorContainerCollection(IEqualityComparer<string> comparer)
Parameters
Type Name Description
IEqualityComparer<string> comparer

The comparer for behaviors.

Properties

Comparer

Gets the comparer used to identify elements.

Declaration
public IEqualityComparer<string> Comparer { get; }
Property Value
Type Description
IEqualityComparer<string>

The comparer.

Count

Gets the number of behavior containers in the collection.

Declaration
public int Count { get; }
Property Value
Type Description
int

The number of behavior containers.

this[string]

Gets the IBehaviorContainer with the specified name.

Declaration
public virtual IBehaviorContainer this[string name] { get; }
Parameters
Type Name Description
string name

The name.

Property Value
Type Description
IBehaviorContainer

The IBehaviorContainer.

Exceptions
Type Condition
ArgumentNullException

Thrown if name is null.

BehaviorsNotFoundException

Thrown if the behavior container of the specified name could not be found.

Keys

Gets the behavior container names.

Declaration
public IEnumerable<string> Keys { get; }
Property Value
Type Description
IEnumerable<string>

An IEnumerable<T> object that contains the name of each BehaviorContainer.

Methods

Add(IBehaviorContainer)

Adds the IBehaviorContainer with the specified name.

Declaration
public void Add(IBehaviorContainer behaviors)
Parameters
Type Name Description
IBehaviorContainer behaviors
Exceptions
Type Condition
ArgumentNullException

Thrown if container if null.

ArgumentException

Thrown if a behavior container already exists with the same name.

Clear()

Clears all containers in the collection.

Declaration
public virtual void Clear()

Contains(string)

Determines whether this instance contains a container by the specified name.

Declaration
public virtual bool Contains(string name)
Parameters
Type Name Description
string name

The name.

Returns
Type Description
bool

true if the collection contains the container; otherwise, false.

Exceptions
Type Condition
ArgumentNullException

Thrown if name is null.

GetBehaviorList<T>()

Gets a list of behaviors of a specific behavior type.

Declaration
public virtual BehaviorList<T> GetBehaviorList<T>() where T : IBehavior
Returns
Type Description
BehaviorList<T>

A BehaviorList<T> with all behaviors of the specified type.

Type Parameters
Name Description
T

GetEnumerator()

Returns an enumerator that iterates through the collection.

Declaration
public IEnumerator<IBehaviorContainer> GetEnumerator()
Returns
Type Description
IEnumerator<IBehaviorContainer>

An enumerator that can be used to iterate through the collection.

OnBehaviorsNotFound(BehaviorsNotFoundEventArgs)

Raises the BehaviorsNotFound event.

Declaration
protected virtual void OnBehaviorsNotFound(BehaviorsNotFoundEventArgs args)
Parameters
Type Name Description
BehaviorsNotFoundEventArgs args

The BehaviorsNotFoundEventArgs instance containing the event data.

TryGetBehaviors(string, out IBehaviorContainer)

Tries to get the behavior container associated with the specified name.

Declaration
public virtual bool TryGetBehaviors(string name, out IBehaviorContainer ebd)
Parameters
Type Name Description
string name

The name.

IBehaviorContainer ebd
Returns
Type Description
bool

true if the behavior was found; otherwise false.

Exceptions
Type Condition
ArgumentNullException

Thrown if name is null.

Events

BehaviorsNotFound

Occurs when a behavior has not been found.

Declaration
public event EventHandler<BehaviorsNotFoundEventArgs> BehaviorsNotFound
Event Type
Type Description
EventHandler<BehaviorsNotFoundEventArgs>

Implements

IBehaviorContainerCollection
IEnumerable<T>
IEnumerable

Extension Methods

Utility.ThrowIfNull<T>(T, string)
Utility.ThrowIfEmpty<T>(IEnumerable<T>, string)

See Also

IBehaviorContainerCollection
In this article
Back to top Generated by DocFX