Class Property<TContainer, TValue>
Base class for implementing properties. This is an abstract class.
Namespace: Unity.Properties
Syntax
public abstract class Property<TContainer, TValue> : object, IProperty<TContainer>, IProperty, IPropertyAccept<TContainer>, IAttributes
Type Parameters
Name | Description |
---|---|
TContainer | The container type this property operates on. |
TValue | The value type for this property. |
Remarks
A IProperty is used as an accessor to the underlying data of a container.
Properties
IsReadOnly
Gets a value indicating whether the property is read-only or not.
Declaration
public abstract bool IsReadOnly { get; }
Property Value
Type | Description |
---|---|
Boolean |
Implements
Name
Gets the name of the property.
Declaration
public abstract string Name { get; }
Property Value
Type | Description |
---|---|
String |
Implements
Methods
AddAttribute(Attribute)
Adds an attribute to the property.
Declaration
protected void AddAttribute(Attribute attribute)
Parameters
Type | Name | Description |
---|---|---|
Attribute | attribute | The attribute to add. |
AddAttributes(IEnumerable<Attribute>)
Adds a set of attributes to the property.
Declaration
protected void AddAttributes(IEnumerable<Attribute> attributes)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Attribute> | attributes | The attributes to add. |
DeclaredValueType()
Returns the declared value type of the property.
Declaration
public Type DeclaredValueType()
Returns
Type | Description |
---|---|
Type | The declared value type. |
Implements
GetAttribute<TAttribute>()
Returns the first attribute of the given type.
Declaration
public TAttribute GetAttribute<TAttribute>()
where TAttribute : Attribute
Returns
Type | Description |
---|---|
TAttribute | The attribute of the given type for this property. |
Type Parameters
Name | Description |
---|---|
TAttribute | The attribute type to get. |
Implements
GetAttributes()
Returns all attribute for this property.
Declaration
public IEnumerable<Attribute> GetAttributes()
Returns
Type | Description |
---|---|
IEnumerable<Attribute> | An |
Implements
GetAttributes<TAttribute>()
Returns all attribute of the given type.
Declaration
public IEnumerable<TAttribute> GetAttributes<TAttribute>()
where TAttribute : Attribute
Returns
Type | Description |
---|---|
IEnumerable<TAttribute> | An |
Type Parameters
Name | Description |
---|---|
TAttribute | The attribute type to get. |
Implements
GetValue(ref TContainer)
Returns the property value of a specified container.
Declaration
public abstract TValue GetValue(ref TContainer container)
Parameters
Type | Name | Description |
---|---|---|
TContainer | container | The container whose property value will be returned. |
Returns
Type | Description |
---|---|
TValue | The property value of the given container. |
HasAttribute<TAttribute>()
Returns true if the property has any attributes of the given type.
Declaration
public bool HasAttribute<TAttribute>()
where TAttribute : Attribute
Returns
Type | Description |
---|---|
Boolean | true if the property has the given attribute type; otherwise, false. |
Type Parameters
Name | Description |
---|---|
TAttribute | The attribute type to check for. |
Implements
SetValue(ref TContainer, TValue)
Sets the property value of a specified container.
Declaration
public abstract void SetValue(ref TContainer container, TValue value)
Parameters
Type | Name | Description |
---|---|---|
TContainer | container | The container whose property value will be set. |
TValue | value | The new property value. |
Explicit Interface Implementations
IProperty<TContainer>.GetValue(ref TContainer)
Returns the property value of a specified container.
Declaration
object IProperty<TContainer>.GetValue(ref TContainer container)
Parameters
Type | Name | Description |
---|---|---|
TContainer | container | The container whose property value will be returned. |
Returns
Type | Description |
---|---|
Object | The property value of the given container. |
Implements
IProperty<TContainer>.TrySetValue(ref TContainer, Object)
Sets the property value of a specified container.
Declaration
bool IProperty<TContainer>.TrySetValue(ref TContainer container, object value)
Parameters
Type | Name | Description |
---|---|---|
TContainer | container | The container whose property value will be set. |
Object | value | The new property value. |
Returns
Type | Description |
---|---|
Boolean |