Class PropertyContainer
The PropertyContainer class is used as the entry point to operate on data containers using properties.
Namespace: Unity.Properties
Syntax
public static class PropertyContainer
Methods
GetProperty(ref Object, PropertyPath)
Gets an IProperty on the specified container for the given PropertyPath.
Declaration
public static IProperty GetProperty(ref object container, PropertyPath path)
Parameters
Type | Name | Description |
---|---|---|
Object | container | The container tree to search. |
PropertyPath | path | The property path to resolve. |
Returns
Type | Description |
---|---|
IProperty | The IProperty for the given path. |
Remarks
While the container data is not actually read from or written to. The container itself is needed to resolve polymorphic fields and list elements.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | The specified container or path is null. |
InvalidContainerTypeException | The specified container type is not valid for visitation. |
MissingPropertyBagException | The specified container type has no property bag associated with it. |
InvalidPathException | The specified |
GetProperty<TContainer>(ref TContainer, PropertyPath)
Gets an IProperty on the specified container for the given PropertyPath.
Declaration
public static IProperty GetProperty<TContainer>(ref TContainer container, PropertyPath path)
Parameters
Type | Name | Description |
---|---|---|
TContainer | container | The container whose property will be returned. |
PropertyPath | path | The property path to resolve. |
Returns
Type | Description |
---|---|
IProperty | The IProperty for the given path. |
Type Parameters
Name | Description |
---|---|
TContainer | The strongly typed container. |
Remarks
While the container data is not actually read from or written to. The container itself is needed to resolve polymorphic fields and list elements.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | The specified container or path is null. |
InvalidContainerTypeException | The specified container type is not valid for visitation. |
MissingPropertyBagException | The specified container type has no property bag associated with it. |
InvalidPathException | The specified |
GetValue<TValue>(ref Object, String)
Gets the value of a property by name.
Declaration
public static TValue GetValue<TValue>(ref object container, string name)
Parameters
Type | Name | Description |
---|---|---|
Object | container | The container whose property value will be returned. |
String | name | The name of the property to get. |
Returns
Type | Description |
---|---|
TValue | The value for the specified name. |
Type Parameters
Name | Description |
---|---|
TValue | The value type. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | The specified container or path is null. |
InvalidContainerTypeException | The specified container type is not valid for visitation. |
MissingPropertyBagException | The specified container type has no property bag associated with it. |
InvalidCastException | The specified |
InvalidPathException | The specified |
GetValue<TValue>(ref Object, PropertyPath)
Gets the value of a property by path.
Declaration
public static TValue GetValue<TValue>(ref object container, PropertyPath path)
Parameters
Type | Name | Description |
---|---|---|
Object | container | The container whose property value will be returned. |
PropertyPath | path | The path of the property to get. |
Returns
Type | Description |
---|---|
TValue | The value at the specified path. |
Type Parameters
Name | Description |
---|---|
TValue | The value type. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | The specified container or path is null. |
InvalidContainerTypeException | The specified container type is not valid for visitation. |
MissingPropertyBagException | The specified container type has no property bag associated with it. |
InvalidCastException | The specified |
InvalidPathException | The specified |
GetValue<TContainer, TValue>(ref TContainer, String)
Gets the value of a property by name.
Declaration
public static TValue GetValue<TContainer, TValue>(ref TContainer container, string name)
Parameters
Type | Name | Description |
---|---|---|
TContainer | container | The container whose property value will be returned. |
String | name | The name of the property to get. |
Returns
Type | Description |
---|---|
TValue | The value for the specified name. |
Type Parameters
Name | Description |
---|---|
TContainer | The container type. |
TValue | The value type. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | The specified container or path is null. |
InvalidContainerTypeException | The specified container type is not valid for visitation. |
MissingPropertyBagException | The specified container type has no property bag associated with it. |
InvalidCastException | The specified |
InvalidPathException | The specified |
GetValue<TContainer, TValue>(ref TContainer, PropertyPath)
Gets the value of a property by path.
Declaration
public static TValue GetValue<TContainer, TValue>(ref TContainer container, PropertyPath path)
Parameters
Type | Name | Description |
---|---|---|
TContainer | container | The container whose property value will be returned. |
PropertyPath | path | The path of the property to get. |
Returns
Type | Description |
---|---|
TValue | The value at the specified path. |
Type Parameters
Name | Description |
---|---|
TContainer | The container type. |
TValue | The value type. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | The specified container or path is null. |
InvalidContainerTypeException | The specified container type is not valid for visitation. |
MissingPropertyBagException | The specified container type has no property bag associated with it. |
InvalidCastException | The specified |
InvalidPathException | The specified |
IsPathValid(ref Object, PropertyPath)
Returns true if a property exists at the specified PropertyPath.
Declaration
public static bool IsPathValid(ref object container, PropertyPath path)
Parameters
Type | Name | Description |
---|---|---|
Object | container | The container tree to search. |
PropertyPath | path | The property path to resolve. |
Returns
Type | Description |
---|---|
Boolean | true if a property can be found at path. |
IsPathValid<TContainer>(ref TContainer, PropertyPath)
Returns true if a property exists at the specified PropertyPath.
Declaration
public static bool IsPathValid<TContainer>(ref TContainer container, PropertyPath path)
Parameters
Type | Name | Description |
---|---|---|
TContainer | container | The container tree to search. |
PropertyPath | path | The property path to resolve. |
Returns
Type | Description |
---|---|
Boolean | true if a property can be found at path. |
Type Parameters
Name | Description |
---|---|
TContainer | The container type. |
SetValue<TValue>(ref Object, String, TValue)
Sets the value of a property by name to the given value.
Declaration
public static void SetValue<TValue>(ref object container, string name, TValue value)
Parameters
Type | Name | Description |
---|---|---|
Object | container | The container whose property will be set. |
String | name | The name of the property to set. |
TValue | value | The value to assign to the property. |
Type Parameters
Name | Description |
---|---|
TValue | The value type to set. |
Remarks
This method is NOT thread safe.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | The specified container or path is null. |
InvalidContainerTypeException | The specified container type is not valid for visitation. |
MissingPropertyBagException | The specified container type has no property bag associated with it. |
InvalidCastException | The specified |
InvalidPathException | The specified |
SetValue<TValue>(ref Object, PropertyPath, TValue)
Sets the value of a property at the given path to the given value.
Declaration
public static void SetValue<TValue>(ref object container, PropertyPath path, TValue value)
Parameters
Type | Name | Description |
---|---|---|
Object | container | The container whose property will be set. |
PropertyPath | path | The path of the property to set. |
TValue | value | The value to assign to the property. |
Type Parameters
Name | Description |
---|---|
TValue | The value type to set. |
Remarks
This method is NOT thread safe.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | The specified container or path is null. |
InvalidContainerTypeException | The specified container type is not valid for visitation. |
MissingPropertyBagException | The specified container type has no property bag associated with it. |
InvalidCastException | The specified |
InvalidPathException | The specified |
SetValue<TContainer, TValue>(ref TContainer, String, TValue)
Sets the value of a property by name to the given value.
Declaration
public static void SetValue<TContainer, TValue>(ref TContainer container, string name, TValue value)
Parameters
Type | Name | Description |
---|---|---|
TContainer | container | The container whose property will be set. |
String | name | The name of the property to set. |
TValue | value | The value to assign to the property. |
Type Parameters
Name | Description |
---|---|
TContainer | The container type to set the value on. |
TValue | The value type to set. |
Remarks
This method is NOT thread safe.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | The specified container or path is null. |
InvalidContainerTypeException | The specified container type is not valid for visitation. |
MissingPropertyBagException | The specified container type has no property bag associated with it. |
InvalidCastException | The specified |
InvalidPathException | The specified |
SetValue<TContainer, TValue>(ref TContainer, PropertyPath, TValue)
Sets the value of a property at the given path to the given value.
Declaration
public static void SetValue<TContainer, TValue>(ref TContainer container, PropertyPath path, TValue value)
Parameters
Type | Name | Description |
---|---|---|
TContainer | container | The container whose property will be set. |
PropertyPath | path | The path of the property to set. |
TValue | value | The value to assign to the property. |
Type Parameters
Name | Description |
---|---|
TContainer | The container type to set the value on. |
TValue | The value type to set. |
Remarks
This method is NOT thread safe.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | The specified container or path is null. |
InvalidContainerTypeException | The specified container type is not valid for visitation. |
MissingPropertyBagException | The specified container type has no property bag associated with it. |
InvalidCastException | The specified |
InvalidPathException | The specified |
AccessViolationException | The specified |
TryGetProperty(ref Object, PropertyPath, out IProperty)
Gets an IProperty on the specified container for the given PropertyPath.
Declaration
public static bool TryGetProperty(ref object container, PropertyPath path, out IProperty property)
Parameters
Type | Name | Description |
---|---|---|
Object | container | The container tree to search. |
PropertyPath | path | The property path to resolve. |
IProperty | property | When this method returns, contains the property associated with the specified path, if the property is found; otherwise, null. |
Returns
Type | Description |
---|---|
Boolean | true if the property was found at the specified path; otherwise, false. |
Remarks
While the container data is not actually read from or written to. The container itself is needed to resolve polymorphic fields and list elements.
TryGetProperty<TContainer>(ref TContainer, PropertyPath, out IProperty)
Gets an IProperty on the specified container for the given PropertyPath.
Declaration
public static bool TryGetProperty<TContainer>(ref TContainer container, PropertyPath path, out IProperty property)
Parameters
Type | Name | Description |
---|---|---|
TContainer | container | The container tree to search. |
PropertyPath | path | The property path to resolve. |
IProperty | property | When this method returns, contains the property associated with the specified path, if the property is found; otherwise, null. |
Returns
Type | Description |
---|---|
Boolean | true if the property was found at the specified path; otherwise, false. |
Type Parameters
Name | Description |
---|---|
TContainer | The strongly typed container. |
Remarks
While the container data is not actually read from or written to. The container itself is needed to resolve polymorphic fields and list elements.
TryGetValue<TValue>(ref Object, String, out TValue)
Gets the value of a property by name.
Declaration
public static bool TryGetValue<TValue>(ref object container, string name, out TValue value)
Parameters
Type | Name | Description |
---|---|---|
Object | container | The container whose property value will be returned. |
String | name | The name of the property to get. |
TValue | value | When this method returns, contains the value associated with the specified name, if the property is found. otherwise the default value for the |
Returns
Type | Description |
---|---|
Boolean | true if the value exists for the specified name; otherwise, false. |
Type Parameters
Name | Description |
---|---|
TValue | The value type. |
TryGetValue<TValue>(ref Object, PropertyPath, out TValue)
Gets the value of a property by path.
Declaration
public static bool TryGetValue<TValue>(ref object container, PropertyPath path, out TValue value)
Parameters
Type | Name | Description |
---|---|---|
Object | container | The container whose property value will be returned. |
PropertyPath | path | The path of the property to get. |
TValue | value | When this method returns, contains the value associated with the specified path, if the property is found. otherwise the default value for the |
Returns
Type | Description |
---|---|
Boolean | The property value of the given container. |
Type Parameters
Name | Description |
---|---|
TValue | The value type to set. |
TryGetValue<TContainer, TValue>(ref TContainer, String, out TValue)
Gets the value of a property by name.
Declaration
public static bool TryGetValue<TContainer, TValue>(ref TContainer container, string name, out TValue value)
Parameters
Type | Name | Description |
---|---|---|
TContainer | container | The container whose property value will be returned. |
String | name | The name of the property to get. |
TValue | value | When this method returns, contains the value associated with the specified name, if the property is found. otherwise the default value for the |
Returns
Type | Description |
---|---|
Boolean | true if the value exists for the specified name; otherwise, false. |
Type Parameters
Name | Description |
---|---|
TContainer | The container type. |
TValue | The value type. |
TryGetValue<TContainer, TValue>(ref TContainer, PropertyPath, out TValue)
Gets the value of a property by path.
Declaration
public static bool TryGetValue<TContainer, TValue>(ref TContainer container, PropertyPath path, out TValue value)
Parameters
Type | Name | Description |
---|---|---|
TContainer | container | The container whose property value will be returned. |
PropertyPath | path | The path of the property to get. |
TValue | value | When this method returns, contains the value associated with the specified path, if the property is found. otherwise the default value for the |
Returns
Type | Description |
---|---|
Boolean | true if the value exists at the specified path; otherwise, false. |
Type Parameters
Name | Description |
---|---|
TContainer | The container type. |
TValue | The value type. |
TrySetValue<TValue>(ref Object, String, TValue)
Tries to set the value of a property at the given path to the given value.
Declaration
public static bool TrySetValue<TValue>(ref object container, string name, TValue value)
Parameters
Type | Name | Description |
---|---|---|
Object | container | The container whose property will be set. |
String | name | The name of the property to set. |
TValue | value | The value to assign to the property. |
Returns
Type | Description |
---|---|
Boolean |
Type Parameters
Name | Description |
---|---|
TValue | The value type to set. |
Remarks
This method is NOT thread safe.
TrySetValue<TValue>(ref Object, PropertyPath, TValue)
Tries to set the value of a property at the given path to the given value.
Declaration
public static bool TrySetValue<TValue>(ref object container, PropertyPath path, TValue value)
Parameters
Type | Name | Description |
---|---|---|
Object | container | The container whose property will be set. |
PropertyPath | path | The path of the property to set. |
TValue | value | The value to assign to the property. |
Returns
Type | Description |
---|---|
Boolean |
Type Parameters
Name | Description |
---|---|
TValue | The value type to set. |
Remarks
This method is NOT thread safe.
TrySetValue<TContainer, TValue>(ref TContainer, String, TValue)
Tries to set the value of a property at the given path to the given value.
Declaration
public static bool TrySetValue<TContainer, TValue>(ref TContainer container, string name, TValue value)
Parameters
Type | Name | Description |
---|---|---|
TContainer | container | The container whose property will be set. |
String | name | The name of the property to set. |
TValue | value | The value to assign to the property. |
Returns
Type | Description |
---|---|
Boolean |
Type Parameters
Name | Description |
---|---|
TContainer | The container type to set the value on. |
TValue | The value type to set. |
Remarks
This method is NOT thread safe.
TrySetValue<TContainer, TValue>(ref TContainer, PropertyPath, TValue)
Tries to set the value of a property at the given path to the given value.
Declaration
public static bool TrySetValue<TContainer, TValue>(ref TContainer container, PropertyPath path, TValue value)
Parameters
Type | Name | Description |
---|---|---|
TContainer | container | The container whose property will be set. |
PropertyPath | path | The path of the property to set. |
TValue | value | The value to assign to the property. |
Returns
Type | Description |
---|---|
Boolean |
Type Parameters
Name | Description |
---|---|
TContainer | The container type to set the value on. |
TValue | The value type to set. |
Remarks
This method is NOT thread safe.
Visit(Object, PropertyVisitor, VisitParameters)
Visit the specified container
using the specified visitor
.
Declaration
public static void Visit(object container, PropertyVisitor visitor, VisitParameters parameters = default(VisitParameters))
Parameters
Type | Name | Description |
---|---|---|
Object | container | The container to visit. |
PropertyVisitor | visitor | The visitor. |
VisitParameters | parameters | The visit parameters to use. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | The container is null. |
InvalidContainerTypeException | The given container type is not valid for visitation. |
MissingPropertyBagException | No property bag was found for the given container. |
Visit<TContainer>(TContainer, PropertyVisitor, VisitParameters)
Visit the specified container
using the specified visitor
.
Declaration
public static void Visit<TContainer>(TContainer container, PropertyVisitor visitor, VisitParameters parameters = default(VisitParameters))
Parameters
Type | Name | Description |
---|---|---|
TContainer | container | The container to visit. |
PropertyVisitor | visitor | The visitor. |
VisitParameters | parameters | The visit parameters to use. |
Type Parameters
Name | Description |
---|---|
TContainer | The declared container type. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | The container is null. |
InvalidContainerTypeException | The given container type is not valid for visitation. |
MissingPropertyBagException | No property bag was found for the given container. |
Visit<TContainer>(ref TContainer, PropertyVisitor, PropertyPath, VisitParameters)
Visit the specified container
using the specified visitor
at the given PropertyPath.
Declaration
public static void Visit<TContainer>(ref TContainer container, PropertyVisitor visitor, PropertyPath path, VisitParameters parameters = default(VisitParameters))
Parameters
Type | Name | Description |
---|---|---|
TContainer | container | The container to visit. |
PropertyVisitor | visitor | The visitor. |
PropertyPath | path | The property path to visit. |
VisitParameters | parameters | The visit parameters to use. |
Type Parameters
Name | Description |
---|---|
TContainer | The container type. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | The container is null. |
InvalidContainerTypeException | The given container type is not valid for visitation. |
MissingPropertyBagException | No property bag was found for the given container. |
Visit<TContainer>(ref TContainer, PropertyVisitor, VisitParameters)
Visit the specified container
using the specified visitor
.
Declaration
public static void Visit<TContainer>(ref TContainer container, PropertyVisitor visitor, VisitParameters parameters = default(VisitParameters))
Parameters
Type | Name | Description |
---|---|---|
TContainer | container | The container to visit. |
PropertyVisitor | visitor | The visitor. |
VisitParameters | parameters | The visit parameters to use. |
Type Parameters
Name | Description |
---|---|
TContainer | The declared container type. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | The container is null. |
InvalidContainerTypeException | The given container type is not valid for visitation. |
MissingPropertyBagException | No property bag was found for the given container. |