Class ComponentBaseExtensions
Extensions for IComponent.
public static class ComponentBaseExtensions
- Inheritance
-
objectComponentBaseExtensions
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
thisArgTThe component to keep alive.
containerICollectorHolderThe container that will keep a reference to the component.
Returns
- T
The same component instance
Type Parameters
TA component
KeepReference<T>(T)
Pins this component as a new reference.
public static T? KeepReference<T>(this T thisArg) where T : IReferencable
Parameters
thisArgTThe component to add a reference to.
Returns
- T
This component.
Type Parameters
TA 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
componentComponentBaseThe component.
keyPropertyKey<T>The key.
valueTThe 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
thisArgTThe component to keep alive.
containerICollectorHolderThe container that will keep a reference to the component.
Returns
- T
The same component instance
Type Parameters
TA 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
thisArgTThe component to remove.
containerICollectorHolderThe container that kept a reference to the component.
Type Parameters
TA 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
thisArgTThe component to remove.
containerICollectorHolderThe container that kept a reference to the component.
Type Parameters
TA component