Table of Contents

Class ComponentBaseExtensions

Namespace
Stride.Core
Assembly
Stride.Core.dll

Extensions for IComponent.

public static class ComponentBaseExtensions
Inheritance
object
ComponentBaseExtensions

Methods

DisposeBy<T>(T, ICollectorHolder)

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

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

Parameters

component 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

The type of the Component.

KeepReference<T>(T)

Pins this component as a new reference.

public static T? KeepReference<T>(this T component) where T : IReferencable

Parameters

component T

The Component to add a reference to.

Returns

T

The same Component instance.

Type Parameters

T

The type of the Component.

Remarks

This method is equivalent to calling AddReference() and returning the same component instance.

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

Sets a tag in a Component and removes it after using it.

public static ComponentBaseExtensions.PropertyTagRestore<T> PushTagAndRestore<T>(this ComponentBase component, PropertyKey<T?> key, T value)

Parameters

component ComponentBase

The Component to set a tag for.

key PropertyKey<T>

The key to identify the tag to set.

value T

The value of the tag.

Returns

ComponentBaseExtensions.PropertyTagRestore<T>

A ComponentBaseExtensions.PropertyTagRestore<T> structure that can be used with a using clause (or manually disposed) to set a tag, perform some action, and remove the tag once finished.

Type Parameters

T

The type of the tag.

Remarks

This method is used to set a property value in Tags, perform some actions, and restore the previous value after finishing.

The returned object must be disposed once the original value must be restored. It can be done manually (by calling Dispose()) or automatically with a using clause.

ReleaseBy<T>(T, ICollectorHolder)

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

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

Parameters

component 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

The type of the Component.

RemoveDisposeBy<T>(T, ICollectorHolder)

Removes a disposable object from a container that keeping it alive.

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

Parameters

component T

The Component to remove.

container ICollectorHolder

The container that kept a reference to the Component.

Type Parameters

T

The type of the Component.

RemoveReleaseBy<T>(T, ICollectorHolder)

Removes a referenceable object from a container that keeping it alive.

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

Parameters

component T

The Component to remove.

container ICollectorHolder

The container that kept a reference to the Component.

Type Parameters

T

The type of the Component.