DisposableUtil

Description

static class Tinman.Core.System.DisposableUtil

Provides static helper method for dealing with IDisposables.

See also

CX

Public / Methods

Cast


[OwnerReturn]
public static method Cast → (1)
<T ref : IDisposable>

disposable in : object

The disposable object or null.

returns → T

disposable in if a strong reference of the given type has been acquired, null if the object is no longer valid or is of an incompatible type.

Returns a strong reference of the given type to the given disposable object.

Cast​Own


[OwnerReturn]
public static method CastOwn → (1)
<T ref : IDisposable>

disposable in : IDisposable own

The disposable object or null.

returns → T

disposable in if a strong reference of the given type has been acquired, null if the object is no longer valid or is of an incompatible type.

Returns a strong reference of the given type to the given disposable object.

Dispose​All

2 overloads


[Dispose]
public static method DisposeAll1 → (1)
<T ref : IDisposable>

disposables in : IVector<T> own

The objects to dispose.

Disposes all given objects and sets the corresponding array elements to null.

The variable that holds the given disposables in must be cleared to null after this method has returned in order to guarantee correct resource management.


[Dispose]
public static method DisposeAll2 → (1)
<T ref : IDisposable>

disposables in : IEnumerable<T> own

The objects to dispose.

Disposes all given objects.

The variable that holds the given disposables in must be cleared to null after this method has returned in order to guarantee correct resource management.

Dispose​Or​Delete


public static method DisposeOrDelete → (1)

obj in : object

The object on which the calling code holds ownership or null.

Disposes the given object if it is an instance of IDisposable, otherwise deletes it if it is an instance of IDeletable, otherwise performs no action.

Using this method circumvents the coding rules for ownership and should be used only in specific scenarios. For usual cases, please use CX.Dispose.

Dispose​Values


[Dispose]
public static method DisposeValues → (1)
<T1>
<T2 ref : IDisposable>

disposables in : IMapConst<T1, T2> own

The objects to dispose.

Disposes all value objects of the given dictionary.

The variable that holds the given disposables in must be cleared to null after this method has returned in order to guarantee correct resource management.

Is​Disposed


public static method IsDisposed → (1)

disposable in : IDisposable

The disposable object.

returns → bool

true if disposable in is no longer valid, false if it still is.

Tests if the given object is no longer valid (i.e. it has left the LifecycleState.Initialized state).

Is​Valid


[Pure]
public static method IsValid → (1)

obj in : object

The object to check.

returns → bool

true if the object is valid, false if not.

Is this object valid (see remarks)?

An object is considered valid if it is in one of the following lifecycle states:

A non-null object that does not implement the ILifecycleState interface is always valid. Null objects are always invalid.