Method Add
Add<T>(T, Action)
Adds an IDisposable which encapsulates an action to an ICollection of IDisposable.
Declaration
public static T Add<T>(this T instance, Action action) where T : ICollection<IDisposable>
Parameters
Type | Name | Description |
---|---|---|
T | instance | The ICollection<IDisposable> to which the item will be added. |
Action | action | The action to encapsulate in an IDisposable using Disposable.Create. |
Returns
Type | Description |
---|---|
T | The modified collection with the added IDisposable. |
Type Parameters
Name | Description |
---|---|
T | The type of the collection, which must be an ICollection<IDisposable>. |
Add<T, TItem>(T, Func<TItem>)
Adds an IDisposable object to an ICollection of IDisposable, and registers a dispose action for it.
Declaration
public static T Add<T, TItem>(this T instance, Func<TItem> accessor) where T : ICollection<IDisposable> where TItem : IDisposable
Parameters
Type | Name | Description |
---|---|---|
T | instance | The ICollection<IDisposable> to which the item will be added. |
Func<TItem> | accessor | A function that returns the item to add to the collection. |
Returns
Type | Description |
---|---|
T | The modified collection with the added item. |
Type Parameters
Name | Description |
---|---|
T | The type of the collection, which must be an ICollection<IDisposable>. |
TItem | The type of the item to add, which must derive from IDisposable. |
Add<T, TItem>(T, Func<IEnumerable<TItem>>)
Adds a set of IDisposable objects to an ICollection of IDisposable, and registers a dispose action for them.
Declaration
public static T Add<T, TItem>(this T instance, Func<IEnumerable<TItem>> itemsAccessor) where T : ICollection<IDisposable> where TItem : IDisposable
Parameters
Type | Name | Description |
---|---|---|
T | instance | The ICollection<IDisposable> to which to add the items. |
Func<IEnumerable<TItem>> | itemsAccessor | A function that returns an IEnumerable of items to add to the collection. |
Returns
Type | Description |
---|---|
T | The modified collection with the added items. |
Type Parameters
Name | Description |
---|---|
T | The type of the collection, which must be an ICollection<IDisposable>. |
TItem | The type of the items to add, which must derive from IDisposable. |