Class PropertyBag
The PropertyBag class provides access to registered property bag instances.
Inherited Members
Namespace: Unity.Properties
Syntax
public static class PropertyBag
Methods
AcceptWithSpecializedVisitor<TContainer>(IPropertyBag<TContainer>, IPropertyBagVisitor, ref TContainer)
Accepts visitation for the given property bag and tries to invoke the most specialized visitor first.
Declaration
public static void AcceptWithSpecializedVisitor<TContainer>(IPropertyBag<TContainer> properties, IPropertyBagVisitor visitor, ref TContainer container)
Parameters
| Type | Name | Description |
|---|---|---|
| IPropertyBag<TContainer> | properties | The property bag to visit. |
| IPropertyBagVisitor | visitor | The visitor or specialized visitor to invoke. |
| TContainer | container | The container being visited. |
Type Parameters
| Name | Description |
|---|---|
| TContainer | The container type. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The given property bag is null. |
CreateInstance<TContainer>()
Constructs a new instance of the given
Declaration
public static TContainer CreateInstance<TContainer>()
Returns
| Type | Description |
|---|---|
| TContainer | A new instance of |
Type Parameters
| Name | Description |
|---|---|
| TContainer | The container type to construct. |
Exists(Type)
Returns true if a property bag exists for the given type.
Declaration
public static bool Exists(Type type)
Parameters
| Type | Name | Description |
|---|---|---|
| Type | type | The type to check for a property bag |
Returns
| Type | Description |
|---|---|
| Boolean | true if there is a property bag for the given type; otherwise, false. |
Exists<TContainer>()
Returns true if a property bag exists for the given type.
Declaration
public static bool Exists<TContainer>()
Returns
| Type | Description |
|---|---|
| Boolean | true if there is a property bag for the given type; otherwise, false. |
Type Parameters
| Name | Description |
|---|---|
| TContainer | The container type to check a property bag for. |
GetAllTypesWithAPropertyBag()
Returns all the Type that have a registered property bag.
Declaration
public static IEnumerable<Type> GetAllTypesWithAPropertyBag()
Returns
| Type | Description |
|---|---|
| IEnumerable<Type> | A list of types with a registered property bag. |
GetPropertyBag(Type)
Gets an interface to the PropertyBag<TContainer> for the given type.
Declaration
public static IPropertyBag GetPropertyBag(Type type)
Parameters
| Type | Name | Description |
|---|---|---|
| Type | type | The container type to resolve the property bag for. |
Returns
| Type | Description |
|---|---|
| IPropertyBag | The resolved property bag. |
Remarks
The returned IPropertyBag can be used to get the strongly typed generic using the
GetPropertyBag<TContainer>()
Gets the strongly typed PropertyBag<TContainer> for the given TContainer.
Declaration
public static IPropertyBag<TContainer> GetPropertyBag<TContainer>()
Returns
| Type | Description |
|---|---|
| IPropertyBag<TContainer> | The resolved property bag, strongly typed. |
Type Parameters
| Name | Description |
|---|---|
| TContainer | The container type to resolve the property bag for. |
Register<TContainer>(PropertyBag<TContainer>)
Registers a strongly typed PropertyBag<TContainer> for a type.
Declaration
public static void Register<TContainer>(PropertyBag<TContainer> propertyBag)
Parameters
| Type | Name | Description |
|---|---|---|
| PropertyBag<TContainer> | propertyBag | The PropertyBag<TContainer> to register. |
Type Parameters
| Name | Description |
|---|---|
| TContainer | The container type this property bag describes. |
RegisterArray<TElement>()
Creates and registers a IPropertyBag<TContainer> for a built in array type.
Declaration
public static void RegisterArray<TElement>()
Type Parameters
| Name | Description |
|---|---|
| TElement | The element type to register. |
Remarks
To generate AOT paths for visitors use RegisterArray<TContainer, TElement>() instead.
RegisterArray<TContainer, TElement>()
Creates and registers a IPropertyBag<TContainer> for a built in array type.
Declaration
public static void RegisterArray<TContainer, TElement>()
Type Parameters
| Name | Description |
|---|---|
| TContainer | The container type to register. |
| TElement | The element type to register. |
Remarks
The container is required to provide AOT code paths for PropertyVisitor.
RegisterDictionary<TKey, TValue>()
Creates and registers a IPropertyBag<TContainer> for a Dictionary<TKey,TValue> type.
Declaration
public static void RegisterDictionary<TKey, TValue>()
Type Parameters
| Name | Description |
|---|---|
| TKey | The key type to register. |
| TValue | The value type to register. |
Remarks
To generate AOT paths for visitors use RegisterDictionary<TContainer, TKey, TValue>() instead.
RegisterDictionary<TContainer, TKey, TValue>()
Creates and registers a IPropertyBag<TContainer> for a Dictionary<TKey,TValue> type.
Declaration
public static void RegisterDictionary<TContainer, TKey, TValue>()
Type Parameters
| Name | Description |
|---|---|
| TContainer | The container type to register. |
| TKey | The key type to register. |
| TValue | The value type to register. |
Remarks
The container is required to provide AOT code paths for PropertyVisitor.
RegisterHashSet<TElement>()
Creates and registers a IPropertyBag<TContainer> for a HashSet<T> type.
Declaration
public static void RegisterHashSet<TElement>()
Type Parameters
| Name | Description |
|---|---|
| TElement | The element type to register. |
Remarks
To generate AOT paths for visitors use RegisterHashSet<TContainer, TElement>() instead.
RegisterHashSet<TContainer, TElement>()
Creates and registers a IPropertyBag<TContainer> for a HashSet<T> type.
Declaration
public static void RegisterHashSet<TContainer, TElement>()
Type Parameters
| Name | Description |
|---|---|
| TContainer | The container type to register. |
| TElement | The element type to register. |
Remarks
The container is required to provide AOT code paths for PropertyVisitor.
RegisterIDictionary<TDictionary, TKey, TValue>()
Creates and registers a IPropertyBag<TContainer> for the specified IDictionary<TKey,TValue> type.
Declaration
public static void RegisterIDictionary<TDictionary, TKey, TValue>()
where TDictionary : IDictionary<TKey, TValue>
Type Parameters
| Name | Description |
|---|---|
| TDictionary | The generic dictionary type to register. |
| TKey | The key type to register. |
| TValue | The value type to register. |
Remarks
To generate AOT paths for visitors use RegisterIDictionary<TContainer, TDictionary, TKey, TValue>() instead.
RegisterIDictionary<TContainer, TDictionary, TKey, TValue>()
Creates and registers a IPropertyBag<TContainer> for the specified IDictionary<TKey,TValue> type.
Declaration
public static void RegisterIDictionary<TContainer, TDictionary, TKey, TValue>()
where TDictionary : IDictionary<TKey, TValue>
Type Parameters
| Name | Description |
|---|---|
| TContainer | The container type to register. |
| TDictionary | The generic dictionary type to register. |
| TKey | The key type to register. |
| TValue | The value type to register. |
Remarks
The container is required to provide AOT code paths for PropertyVisitor.
RegisterIList<TList, TElement>()
Creates and registers a IPropertyBag<TContainer> for the specified IList<T> type.
Declaration
public static void RegisterIList<TList, TElement>()
where TList : IList<TElement>
Type Parameters
| Name | Description |
|---|---|
| TList | The generic list type to register. |
| TElement | The element type to register. |
Remarks
To generate AOT paths for visitors use RegisterIList<TContainer, TList, TElement>() instead.
RegisterIList<TContainer, TList, TElement>()
Creates and registers a IPropertyBag<TContainer> for the specified IList<T> type.
Declaration
public static void RegisterIList<TContainer, TList, TElement>()
where TList : IList<TElement>
Type Parameters
| Name | Description |
|---|---|
| TContainer | The container type to register. |
| TList | The generic list type to register. |
| TElement | The element type to register. |
Remarks
The container is required to provide AOT code paths for PropertyVisitor.
RegisterISet<TSet, TElement>()
Creates and registers a IPropertyBag<TContainer> for the specified
Declaration
public static void RegisterISet<TSet, TElement>()
where TSet : ISet<TElement>
Type Parameters
| Name | Description |
|---|---|
| TSet | The generic set type to register. |
| TElement | The element type to register. |
Remarks
To generate AOT paths for visitors use RegisterISet<TContainer, TSet, TElement>() instead.
RegisterISet<TContainer, TSet, TElement>()
Creates and registers a IPropertyBag<TContainer> for the specified
Declaration
public static void RegisterISet<TContainer, TSet, TElement>()
where TSet : ISet<TElement>
Type Parameters
| Name | Description |
|---|---|
| TContainer | The container type to register. |
| TSet | The generic set type to register. |
| TElement | The element type to register. |
Remarks
The container is required to provide AOT code paths for PropertyVisitor.
RegisterList<TElement>()
Creates and registers a IPropertyBag<TContainer> for a List<T> type.
Declaration
public static void RegisterList<TElement>()
Type Parameters
| Name | Description |
|---|---|
| TElement | The element type to register. |
Remarks
To generate AOT paths for visitors use RegisterList<TContainer, TElement>() instead.
RegisterList<TContainer, TElement>()
Creates and registers a IPropertyBag<TContainer> for a List<T> type.
Declaration
public static void RegisterList<TContainer, TElement>()
Type Parameters
| Name | Description |
|---|---|
| TContainer | The container type to register. |
| TElement | The element type to register. |
Remarks
The container is required to provide AOT code paths for PropertyVisitor.
TryGetPropertyBagForValue<TValue>(ref TValue, out IPropertyBag)
Gets a property bag for the concrete type of the given value.
Declaration
public static bool TryGetPropertyBagForValue<TValue>(ref TValue value, out IPropertyBag propertyBag)
Parameters
| Type | Name | Description |
|---|---|---|
| TValue | value | The value type to retrieve a property bag for. |
| IPropertyBag | propertyBag | When this method returns, contains the property bag associated with the specified value, if the bag is found; otherwise, null. |
Returns
| Type | Description |
|---|---|
| Boolean | true if the property bag was found for the specified value; otherwise, false. |
Type Parameters
| Name | Description |
|---|---|
| TValue |