Class IndexedCollectionPropertyBag<TList, TElement>
An IPropertyBag<TContainer> implementation for a generic collection of elements which can be accessed by index. This is based on the IList<T> interface.
Inherited Members
Namespace: Unity.Properties
Syntax
public class IndexedCollectionPropertyBag<TList, TElement> : PropertyBag<TList>, IPropertyBagRegister, IConstructor<TList>, IListPropertyBag<TList, TElement>, ICollectionPropertyBag<TList, TElement>, IPropertyBag<TList>, IPropertyBag, ICollectionPropertyBagAccept<TList>, IListPropertyBagAccept<TList>, IListPropertyAccept<TList>, IIndexedProperties<TList>, IConstructorWithCount<TList>, IConstructor, IIndexedCollectionPropertyBagEnumerator<TList> where TList : IList<TElement>
Type Parameters
Name | Description |
---|---|
TList | The collection type. |
TElement | The element type. |
Methods
GetProperties()
Returns an enumerator that iterates through all static properties for the type.
Declaration
public override PropertyCollection<TList> GetProperties()
Returns
Type | Description |
---|---|
PropertyCollection<TList> | A IEnumerator<T> structure for all properties. |
Overrides
Implements
Remarks
This should return a subset properties returned by GetProperties(ref TContainer).
GetProperties(ref TList)
Returns an enumerator that iterates through all static and dynamic properties for the given container.
Declaration
public override PropertyCollection<TList> GetProperties(ref TList container)
Parameters
Type | Name | Description |
---|---|---|
TList | container |
Returns
Type | Description |
---|---|
PropertyCollection<TList> | A IEnumerator<T> structure for all properties. |
Overrides
Implements
Remarks
This should return all static properties returned by GetProperties() in addition to any dynamic properties. If the container is a collection type all elements will be iterated.
InstantiateWithCount(Int32)
Implement this method to provide custom type instantiation with a count value for the container type.
Declaration
protected virtual TList InstantiateWithCount(int count)
Parameters
Type | Name | Description |
---|---|---|
Int32 | count | The requested capacity. |
Returns
Type | Description |
---|---|
TList | A new instance of |
Remarks
You MUST also override InstantiationKind to return langword_csharp_ConstructionType.PropertyBagOverride for this method to be called.
TryGetProperty(ref TList, Int32, out IProperty<TList>)
Gets the property associated with the specified index.
Declaration
public bool TryGetProperty(ref TList container, int index, out IProperty<TList> property)
Parameters
Type | Name | Description |
---|---|---|
TList | container | The container hosting the data. |
Int32 | index | The index of the property to get. |
IProperty<TList> | property | When this method returns, contains the property associated with the specified index, if the name is found; otherwise, null. |
Returns
Type | Description |
---|---|
Boolean | true if the IIndexedProperties<TContainer> contains a property for the specified index; otherwise, false. |
Implements
Explicit Interface Implementations
ICollectionPropertyBagAccept<TList>.Accept(ICollectionPropertyBagVisitor, ref TList)
Call this method to invoke Visit<TCollection, TElement>(ICollectionPropertyBag<TCollection, TElement>, ref TCollection) with the strongly typed container.
Declaration
void ICollectionPropertyBagAccept<TList>.Accept(ICollectionPropertyBagVisitor visitor, ref TList container)
Parameters
Type | Name | Description |
---|---|---|
ICollectionPropertyBagVisitor | visitor | The visitor being run. |
TList | container |
Implements
IListPropertyAccept<TList>.Accept<TContainer>(IListPropertyVisitor, Property<TContainer, TList>, ref TContainer, ref TList)
Call this method to invoke Visit<TList, TElement>(IListPropertyBag<TList, TElement>, ref TList) with the strongly typed container.
Declaration
void IListPropertyAccept<TList>.Accept<TContainer>(IListPropertyVisitor visitor, Property<TContainer, TList> property, ref TContainer container, ref TList list)
Parameters
Type | Name | Description |
---|---|---|
IListPropertyVisitor | visitor | The visitor being run. |
Property<TContainer, TList> | property | The property being visited. |
TContainer | container | The container being visited. |
TList | list | The list value. |
Type Parameters
Name | Description |
---|---|
TContainer | The container type. |
Implements
Remarks
This method is used to join the container type and element type.
IListPropertyBagAccept<TList>.Accept(IListPropertyBagVisitor, ref TList)
Call this method to invoke Visit<TList, TElement>(IListPropertyBag<TList, TElement>, ref TList) with the strongly typed container.
Declaration
void IListPropertyBagAccept<TList>.Accept(IListPropertyBagVisitor visitor, ref TList list)
Parameters
Type | Name | Description |
---|---|---|
IListPropertyBagVisitor | visitor | The visitor being run. |
TList | list |