Class ComponentBaseExtensions
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
TThe component to keep alive.
container
ICollectorHolderThe 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
TThe 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
ComponentBaseThe component.
key
PropertyKey<T>The key.
value
TThe 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
TThe component to keep alive.
container
ICollectorHolderThe 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
TThe component to remove.
container
ICollectorHolderThe 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
TThe component to remove.
container
ICollectorHolderThe container that kept a reference to the component.
Type Parameters
T
A component