Public Member Functions | |
AutoDisposable () | |
Default constructor. | |
AutoDisposable (RefType res) | |
Value constructor. | |
AutoDisposable (ref RefType res) | |
Reference constructor. | |
void | Reset (RefType res) |
Replaces the resource it holds with a new one. | |
void | Reset (ref RefType res) |
Replaces the resource it holds with a new one. | |
void | Reset () |
Disposes of the resource it holds. | |
void | Release (out RefType res) |
Relinquishes control over the resource it holds. | |
Static Public Member Functions | |
static implicit | operator RefType (AutoDisposable< RefType > ar) |
Implicit conversion operator. | |
Protected Member Functions | |
override void | Dispose (bool disposing) |
Implements the IDisposable protocol. See the DisposableBase class for details. | |
Properties | |
bool | Empty [get] |
Indicates whether a resource is being held. |
Obviates the limitations of the using statement. Ensures correct handling of resources within constructors and makes it possible to conditionally construct IDisposable's within using statements. Expects to own resources exclusively, even though such a constraint cannot be enforced completely.
RefType | The IDisposable descendant to be managed. |
RefType | : | class | |
RefType | : | IDisposable |
DotNX::Core::AutoDisposable< RefType >::AutoDisposable | ( | ) |
Default constructor.
Initialises an instance to hold a null reference.
DotNX::Core::AutoDisposable< RefType >::AutoDisposable | ( | RefType | res | ) |
Value constructor.
res | The resource to be managed, usually directly constructed. |
DotNX::Core::AutoDisposable< RefType >::AutoDisposable | ( | ref RefType | res | ) |
Reference constructor.
res | A reference to an already constructed resource, which is set to null to enforce single ownership. |
static implicit DotNX::Core::AutoDisposable< RefType >::operator RefType | ( | AutoDisposable< RefType > | ar | ) | [static] |
Implicit conversion operator.
The resource is kept under AutoDisposable's control.
ar | An AutoDisposable to a resource type. |
void DotNX::Core::AutoDisposable< RefType >::Reset | ( | RefType | res | ) |
Replaces the resource it holds with a new one.
The resource held originally is disposed of.
res | The new resource to handle. |
void DotNX::Core::AutoDisposable< RefType >::Reset | ( | ref RefType | res | ) |
Replaces the resource it holds with a new one.
The reference variant of the previous method, which sets its argument to null.
res | The new resource to handle. |
void DotNX::Core::AutoDisposable< RefType >::Reset | ( | ) |
Disposes of the resource it holds.
void DotNX::Core::AutoDisposable< RefType >::Release | ( | out RefType | res | ) |
Relinquishes control over the resource it holds.
res | the resource. |
override void DotNX::Core::AutoDisposable< RefType >::Dispose | ( | bool | disposing | ) | [protected, virtual] |
Implements the IDisposable protocol. See the DisposableBase class for details.
disposing | Indicates whether fields requiring explicit cleanup should be dealt with. |
Implements DotNX::Core::DisposableBase.
bool DotNX::Core::AutoDisposable< RefType >::Empty [get] |
Indicates whether a resource is being held.