Class IObjectExtensions
Provides extension methods for disposing objects that may or may not implement IDisposable.
Inherited Members
Namespace: TriLibCore.Extensions
Assembly: TriLibCore.dll
Syntax
public static class IObjectExtensions
Methods
TryToDispose<T>(IList<T>)
Attempts to dispose the specified IList<T> if it implements IDisposable.
Declaration
public static void TryToDispose<T>(this IList<T> obj)
Parameters
| Type | Name | Description |
|---|---|---|
| IList<T> | obj | The IList<T> to attempt disposing. |
Type Parameters
| Name | Description |
|---|---|
| T | The type parameter representing the items of the list. |
Remarks
If obj does not implement IDisposable, this method will do nothing.
No exception will be thrown if the cast to IDisposable fails.
TryToDispose<T>(object)
Attempts to dispose the specified obj if it implements IDisposable.
Declaration
public static void TryToDispose<T>(this object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj | The object to attempt disposing. |
Type Parameters
| Name | Description |
|---|---|
| T | The type parameter representing the object's value type. |
Remarks
If obj does not implement IDisposable, this method will do nothing.
No exception will be thrown if the cast to IDisposable fails.