docs.unity3d.com
    Show / Hide Table of Contents

    Class PropertyBag<TContainer>

    Base class for implementing a property bag for a specified container type. This is an abstract class.

    Inheritance
    Object
    PropertyBag<TContainer>
    ContainerPropertyBag<TContainer>
    IndexedCollectionPropertyBag<TList, TElement>
    KeyValueCollectionPropertyBag<TDictionary, TKey, TValue>
    KeyValuePairPropertyBag<TKey, TValue>
    SetPropertyBagBase<TSet, TElement>
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Unity.Properties
    Syntax
    public abstract class PropertyBag<TContainer> : IPropertyBag<TContainer>, IPropertyBag, IPropertyBagRegister, IConstructor<TContainer>, IConstructor
    Type Parameters
    Name Description
    TContainer

    The container type.

    Remarks

    This is used as the base class internally and should NOT be extended.

    When implementing custom property bags use:

    • ContainerPropertyBag<TContainer>.
    • IndexedCollectionPropertyBag<TList, TElement>.

    Properties

    InstantiationKind

    Implement this property and return true to provide custom type instantiation for the container type.

    Declaration
    protected virtual InstantiationKind InstantiationKind { get; }
    Property Value
    Type Description
    InstantiationKind

    Methods

    Accept(ITypeVisitor)

    Accepts visitation from a specified ITypeVisitor.

    Declaration
    public void Accept(ITypeVisitor visitor)
    Parameters
    Type Name Description
    ITypeVisitor visitor

    The visitor handling visitation.

    Implements
    IPropertyBag.Accept(ITypeVisitor)
    Exceptions
    Type Condition
    ArgumentNullException

    The visitor is null.

    CreateInstance()

    Creates and returns a new instance of .

    Declaration
    public TContainer CreateInstance()
    Returns
    Type Description
    TContainer

    A new instance of .

    Implements
    IPropertyBag<TContainer>.CreateInstance()

    GetProperties()

    Implement this method to return a PropertyCollection<TContainer> that can enumerate through all properties for the TContainer.

    Declaration
    public abstract PropertyCollection<TContainer> GetProperties()
    Returns
    Type Description
    PropertyCollection<TContainer>

    A PropertyCollection<TContainer> structure which can enumerate each property.

    GetProperties(ref TContainer)

    Implement this method to return a PropertyCollection<TContainer> that can enumerate through all properties for the TContainer.

    Declaration
    public abstract PropertyCollection<TContainer> GetProperties(ref TContainer container)
    Parameters
    Type Name Description
    TContainer container

    The container hosting the data.

    Returns
    Type Description
    PropertyCollection<TContainer>

    A PropertyCollection<TContainer> structure which can enumerate each property.

    Instantiate()

    Implement this method to provide custom type instantiation for the container type.

    Declaration
    protected virtual TContainer Instantiate()
    Returns
    Type Description
    TContainer

    A new instance of .

    Remarks

    You MUST also override InstantiationKind to return langword_csharp_ConstructionType.PropertyBagOverride for this method to be called.

    TryCreateInstance(out TContainer)

    Tries to create a new instance of .

    Declaration
    public bool TryCreateInstance(out TContainer instance)
    Parameters
    Type Name Description
    TContainer instance

    When this method returns, contains the created instance, if type instantiation succeeded; otherwise, the default value for TContainer.

    Returns
    Type Description
    Boolean

    true if a new instance of type was created; otherwise, false.

    Implements
    IPropertyBag<TContainer>.TryCreateInstance(out TContainer)

    Explicit Interface Implementations

    IPropertyBag.Accept(IPropertyBagVisitor, ref Object)

    Accepts visitation from a specified IPropertyBagVisitor using an object as the container.

    Declaration
    void IPropertyBag.Accept(IPropertyBagVisitor visitor, ref object container)
    Parameters
    Type Name Description
    IPropertyBagVisitor visitor

    The visitor handling the visitation.

    Object container

    The container being visited.

    Implements
    IPropertyBag.Accept(IPropertyBagVisitor, ref Object)
    Exceptions
    Type Condition
    ArgumentNullException

    The container is null.

    InvalidCastException

    The container type does not match the property bag type.

    IPropertyBag<TContainer>.Accept(IPropertyBagVisitor, ref TContainer)

    Accepts visitation from a specified IPropertyBagVisitor using a strongly typed container.

    Declaration
    void IPropertyBag<TContainer>.Accept(IPropertyBagVisitor visitor, ref TContainer container)
    Parameters
    Type Name Description
    IPropertyBagVisitor visitor

    The visitor handling the visitation.

    TContainer container

    The container being visited.

    Implements
    IPropertyBag<TContainer>.Accept(IPropertyBagVisitor, ref TContainer)

    IPropertyBag<TContainer>.GetProperties()

    Returns an enumerator that iterates through all static properties for the type.

    Declaration
    PropertyCollection<TContainer> IPropertyBag<TContainer>.GetProperties()
    Returns
    Type Description
    PropertyCollection<TContainer>

    A IEnumerator<T> structure for all properties.

    Implements
    IPropertyBag<TContainer>.GetProperties()
    Remarks

    This should return a subset properties returned by GetProperties(ref TContainer).

    IPropertyBag<TContainer>.GetProperties(ref TContainer)

    Returns an enumerator that iterates through all static and dynamic properties for the given container.

    Declaration
    PropertyCollection<TContainer> IPropertyBag<TContainer>.GetProperties(ref TContainer container)
    Parameters
    Type Name Description
    TContainer container

    The container hosting the data.

    Returns
    Type Description
    PropertyCollection<TContainer>

    A IEnumerator<T> structure for all properties.

    Implements
    IPropertyBag<TContainer>.GetProperties(ref TContainer)
    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.

    Back to top
    Terms of use
    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