Table of Contents

Class ComponentBaseExtensions

Namespace
Stride.Core
Assembly
Stride.Core.dll

Extensions for IComponent.

public static class ComponentBaseExtensions
Inheritance
ComponentBaseExtensions

Methods

DisposeBy<T>(T, ICollectorHolder)

Keeps a disposable object alive by adding it to a container.

public static T DisposeBy<T>(this T thisArg, ICollectorHolder container) where T : IDisposable

Parameters

thisArg T

The component to keep alive.

container ICollectorHolder

The container that will keep a reference to the component.

Returns

T

The same component instance

Type Parameters

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

thisArg T

The component to add a reference to.

Returns

T

This component.

Type Parameters

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

component ComponentBase

The component.

key PropertyKey<T>

The key.

value T

The value.

Returns

ComponentBaseExtensions.PropertyTagRestore<T>

PropertyTagRestore<T>.

Type Parameters

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.

ReleaseBy<T>(T, ICollectorHolder)

Keeps a referencable object alive by adding it to a container.

public static T ReleaseBy<T>(this T thisArg, ICollectorHolder container) where T : IReferencable

Parameters

thisArg T

The component to keep alive.

container ICollectorHolder

The container that will keep a reference to the component.

Returns

T

The same component instance

Type Parameters

T

A component

RemoveDisposeBy<T>(T, ICollectorHolder)

Removes a disposable object that was being kept alive from a container.

public static void RemoveDisposeBy<T>(this T thisArg, ICollectorHolder container) where T : IDisposable

Parameters

thisArg T

The component to remove.

container ICollectorHolder

The container that kept a reference to the component.

Type Parameters

T

A component

RemoveReleaseBy<T>(T, ICollectorHolder)

Removes a referencable object that was being kept alive from a container.

public static void RemoveReleaseBy<T>(this T thisArg, ICollectorHolder container) where T : IReferencable

Parameters

thisArg T

The component to remove.

container ICollectorHolder

The container that kept a reference to the component.

Type Parameters

T

A component