Class Property<TContainer, TValue> | Properties | 1.1.1-preview
docs.unity3d.com
    Show / Hide Table of Contents

    Class Property<TContainer, TValue>

    Base class for implementing properties. This is an abstract class.

    Inheritance
    Object
    Property<TContainer, TValue>
    DelegateProperty<TContainer, TValue>
    ReflectedMemberProperty<TContainer, TValue>
    Namespace: Unity.Properties
    Syntax
    public abstract class Property<TContainer, TValue> : 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
    IProperty.IsReadOnly

    Name

    Gets the name of the property.

    Declaration
    public abstract string Name { get; }
    Property Value
    Type Description
    String
    Implements
    IProperty.Name

    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
    IProperty.DeclaredValueType()

    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
    IProperty.GetAttribute<TAttribute>()

    GetAttributes()

    Returns all attribute for this property.

    Declaration
    public IEnumerable<Attribute> GetAttributes()
    Returns
    Type Description
    IEnumerable<Attribute>

    An IEnumerable<T> for all attributes.

    Implements
    IProperty.GetAttributes()

    GetAttributes<TAttribute>()

    Returns all attribute of the given type.

    Declaration
    public IEnumerable<TAttribute> GetAttributes<TAttribute>()
        where TAttribute : Attribute
    Returns
    Type Description
    IEnumerable<TAttribute>

    An IEnumerable<T> for all attributes of the given type.

    Type Parameters
    Name Description
    TAttribute

    The attribute type to get.

    Implements
    IProperty.GetAttributes<TAttribute>()

    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
    IProperty.HasAttribute<TAttribute>()

    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)

    Declaration
    object IProperty<TContainer>.GetValue(ref TContainer container)
    Parameters
    Type Name Description
    TContainer container
    Returns
    Type Description
    Object
    Implements
    IProperty<TContainer>.GetValue(ref TContainer)

    IProperty<TContainer>.TrySetValue(ref TContainer, Object)

    Declaration
    bool IProperty<TContainer>.TrySetValue(ref TContainer container, object value)
    Parameters
    Type Name Description
    TContainer container
    Object value
    Returns
    Type Description
    Boolean
    Implements
    IProperty<TContainer>.TrySetValue(ref TContainer, Object)

    Extension Methods

    PropertyVisitExtensions.Visit<TValue>(IProperty, PropertyVisitor, ref TValue)
    PropertyVisitExtensions.Visit<TValue>(IProperty, PropertyVisitor, ref TValue, Int32)
    PropertyVisitExtensions.Visit<TValue>(IProperty, PropertyVisitor, ref TValue, Object)
    PropertyAttributeExtensions.WithAttribute<TProperty>(TProperty, Attribute)
    PropertyAttributeExtensions.WithAttributes<TProperty>(TProperty, IEnumerable<Attribute>)
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023