Stride

OPEN / CLOSE
  • Features
  • Blog
  • Documentation
  • Community
(icon) Download

  • Discord
  • Facebook
  • Twitter
  • YouTube

LANGUAGE

OPEN / CLOSE
  • English
  • 日本語
    Show / Hide Table of Contents

    ComponentBaseExtensions Class

    Namespace: Stride.Core
    Assembly: Stride.Core.dll

    Extensions for IComponent.

    System.Object → ComponentBaseExtensions
    Derived from ComponentBaseExtensions:

    public static class ComponentBaseExtensions
    Name Description
    Methods
    DisposeBy<T>(T, ICollectorHolder)

    Keeps a component alive by adding it to a container.

    KeepReference<T>(T)

    Pins this component as a new reference.

    PushTagAndRestore<T>(ComponentBase, PropertyKey<T>, T)

    Pushes a tag to a component and restore it after using it. See remarks for usage.

    RemoveDisposeBy<T>(T, ICollectorHolder)

    Removes a component that ws being kept alive from a container.

    | Improve this Doc View Source

    Methods


    DisposeBy<T>(T, ICollectorHolder)

    Keeps a component alive by adding it to a container.

    public static T DisposeBy<T>(this T thisArg, ICollectorHolder container)
    Parameters
    Type Name Description
    T thisArg

    The component to keep alive.

    ICollectorHolder container

    The container that will keep a reference to the component.

    Returns
    Type Description
    T

    The same component instance

    Type Parameters
    Name Description
    T

    A component


    KeepReference<T>(T)

    Pins this component as a new reference.

    public static T KeepReference<T>(this T thisArg)
        where T : IReferencable
    Parameters
    Type Name Description
    T thisArg

    The component to add a reference to.

    Returns
    Type Description
    T

    This component.

    Type Parameters
    Name Description
    T

    A component

    Remarks

    This method is equivalent to call AddReference() and return this instance.


    PushTagAndRestore<T>(ComponentBase, PropertyKey<T>, T)

    Pushes a tag to a component and restore it after using it. See remarks for usage.

    public static ComponentBaseExtensions.PropertyTagRestore<T> PushTagAndRestore<T>(this ComponentBase component, PropertyKey<T> key, T value)
    Parameters
    Type Name Description
    ComponentBase component

    The component.

    PropertyKey<T> key

    The key.

    T value

    The value.

    Returns
    Type Description
    ComponentBaseExtensions.PropertyTagRestore<T>

    PropertyTagRestore<T>.

    Type Parameters
    Name Description
    T
    Remarks

    This method is used to set save a property value from Tags, set a new value and restore it after. The returned object must be disposed once the original value must be restored.


    RemoveDisposeBy<T>(T, ICollectorHolder)

    Removes a component that ws being kept alive from a container.

    public static void RemoveDisposeBy<T>(this T thisArg, ICollectorHolder container)
    Parameters
    Type Name Description
    T thisArg

    The component to remove.

    ICollectorHolder container

    The container that kept a reference to the component.

    Type Parameters
    Name Description
    T

    A component


    • Improve this Doc
    • View Source
    In This Article

    Back to top

    Copyright © 2019-2021 .NET Foundation and Contributors
    Supported by the .NET Foundation