ComponentBaseExtensions Class
Namespace: Stride.CoreAssembly: Stride.Core.dll
Extensions for IComponent.
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. |
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 |