Class Wrapper<T>
Represents an abstract wrapper class for a value of type T
that supports equality, cloning, and disposal.
public abstract class Wrapper<T> : Equatable<Wrapper<T>>, ICloneable<Wrapper<T>>, ICloneable, IEquatable<Wrapper<T>>, IComparable<Wrapper<T>>, IComparable, IDisposable
Type Parameters
T
The type of the wrapped value.
- Inheritance
-
Wrapper<T>
- Implements
-
ICloneable<Wrapper<T>>IEquatable<Wrapper<T>>IComparable<Wrapper<T>>
- Inherited Members
- Extension Methods
Constructors
Wrapper()
Initializes a new instance of the Wrapper<T> class.
protected Wrapper()
Wrapper(T)
Initializes a new instance of the Wrapper<T> class with the specified value.
protected Wrapper(T value)
Parameters
value
TThe value to wrap.
Properties
HasValue
Gets a value indicating whether the wrapped value is not equal to the default value of type T
.
public bool HasValue { get; }
Property Value
IsDisposed
Gets a value indicating whether this instance has already been disposed.
public bool IsDisposed { get; }
Property Value
Value
Gets or sets the wrapped value.
public virtual T Value { get; set; }
Property Value
- T
Methods
Dispose()
Releases all resources used by the current instance.
public void Dispose()
DisposeManaged()
Releases managed resources used by the current instance.
protected virtual void DisposeManaged()
DisposeNative()
Releases unmanaged (native) resources used by the current instance.
protected virtual void DisposeNative()
~Wrapper()
Finalizes an instance of the Wrapper<T> class.
protected ~Wrapper()
GetHashCode()
Returns a hash code for this instance based on the wrapped value.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
OnEquals(Wrapper<T>)
Determines whether the wrapped value of this instance equals the wrapped value of another instance.
protected override bool OnEquals(Wrapper<T> other)
Parameters
other
Wrapper<T>Another instance of Wrapper<T> to compare with.
Returns
- bool
true
if the wrapped values are equal; otherwise,false
.
ToString()
Returns a string that represents the current instance.
public override string ToString()
Returns
- string
A string representation of the wrapped value, or an empty string if no value is present.
Operators
explicit operator T(Wrapper<T>)
Defines an explicit conversion operator from Wrapper<T> to T
.
public static explicit operator T(Wrapper<T> wrapper)
Parameters
wrapper
Wrapper<T>The wrapper instance.
Returns
- T
The wrapped value.