Class UnmanagedEnumClass<TSource, TObject>
A class which allows unmanaged data implicit conversions.
Can be used along with unmanaged, means it doesn't require another UnmanagedEnumClass<TSource, TObject> instance to be comparable or usable.
public abstract class UnmanagedEnumClass<TSource, TObject> : IComparable, IEquatable<TObject>, IComparable<TObject>, IComparer<TObject> where TSource : unmanaged, IComparable, IFormattable, IConvertible, IComparable<TSource>, IEquatable<TSource> where TObject : UnmanagedEnumClass<TSource, TObject>Type Parameters
- TSource
- The type of the unmanaged source object to handle the instance of. 
- TObject
- The type of the child object to handle the instance of. 
- Inheritance
- 
      
      UnmanagedEnumClass<TSource, TObject>
- Implements
- 
      
      IEquatable<TObject>IComparable<TObject>IComparer<TObject>
- Inherited Members
- Extension Methods
Constructors
UnmanagedEnumClass(TSource)
Initializes a new instance of the UnmanagedEnumClass<TSource, TObject> class.
protected UnmanagedEnumClass(TSource value)Parameters
- valueTSource
- The value of the unmanaged item. 
Properties
Name
Gets the name determined from reflection.
public string Name { get; }Property Value
Value
Gets the value of the enum item.
public TSource Value { get; }Property Value
- TSource
Values
Gets all TObject object instances.
public static IEnumerable<TObject> Values { get; }Property Value
- IEnumerable<TObject>
Methods
Cast(IEnumerable<TSource>)
Casts the specified values to the corresponding type.
public static IEnumerable<TObject> Cast(IEnumerable<TSource> values)Parameters
- valuesIEnumerable<TSource>
- The enum values to be cast. 
Returns
- IEnumerable<TObject>
- The cast object. 
Cast(TSource)
Casts the specified value to the corresponding type.
public static TObject Cast(TSource value)Parameters
- valueTSource
- The enum value to be cast. 
Returns
- TObject
- The cast object. 
Cast<T>(IEnumerable<TSource>)
Casts the specified values to the corresponding type.
public static IEnumerable<T> Cast<T>(IEnumerable<TSource> values) where T : TObjectParameters
- valuesIEnumerable<TSource>
- The enum values to be cast. 
Returns
- IEnumerable<T>
- The cast - Tobject.
Type Parameters
- T
- The type to cast the enum to. 
Cast<T>(TSource)
Casts the specified value to the corresponding type.
public static T Cast<T>(TSource value) where T : TObjectParameters
- valueTSource
- The enum value to be cast. 
Returns
- T
- The cast - Tobject.
Type Parameters
- T
- The type to cast the enum to. 
Compare(TObject, TObject)
Compares the specified object instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
public int Compare(TObject x, TObject y)Parameters
- xTObject
- An object to compare. 
- yTObject
- Another object to compare. 
Returns
- int
- A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance precedes other in the sort order. Zero This instance occurs in the same position in the sort order as other. Greater than zero This instance follows other in the sort order. 
CompareTo(object)
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
public int CompareTo(object obj)Parameters
- objobject
- An object to compare with this instance. 
Returns
- int
- A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance precedes other in the sort order. Zero This instance occurs in the same position in the sort order as other. Greater than zero This instance follows other in the sort order. 
CompareTo(TObject)
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
public int CompareTo(TObject other)Parameters
- otherTObject
- An object to compare with this instance. 
Returns
- int
- A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance precedes other in the sort order. Zero This instance occurs in the same position in the sort order as other. Greater than zero This instance follows other in the sort order. 
Equals(object)
Determines whether the specified object is equal to the current object.
public override bool Equals(object obj)Parameters
- objobject
- The object to compare. 
Returns
Equals(TObject)
Determines whether the specified object is equal to the current object.
public bool Equals(TObject other)Parameters
- otherTObject
- The object to compare. 
Returns
GetHashCode()
Returns a the 32-bit signed hash code of the current object instance.
public override int GetHashCode()Returns
- int
- The 32-bit signed hash code of the current object instance. 
GetValues(Type)
Retrieves an array of the values of the constants in a specified UnmanagedEnumClass<TSource, TObject>.
public static TSource[] GetValues(Type type)Parameters
- typeType
- The UnmanagedEnumClass<TSource, TObject> type. 
Returns
- TSource[]
- An array of the values of the constants in a specified UnmanagedEnumClass<TSource, TObject>. 
Parse(string)
Parses a string object.
public static TObject Parse(string obj)Parameters
- objstring
- The object to be parsed. 
Returns
- TObject
- The corresponding - TObjectobject instance, or null if not found.
SafeCast(IEnumerable<TSource>, out IEnumerable<TObject>)
Safely casts the specified values to the corresponding type.
public static bool SafeCast(IEnumerable<TSource> values, out IEnumerable<TObject> results)Parameters
- valuesIEnumerable<TSource>
- The enum value to be cast. 
- resultsIEnumerable<TObject>
- The cast - values.
Returns
SafeCast(TSource, out TObject)
Safely casts the specified value to the corresponding type.
public static bool SafeCast(TSource value, out TObject result)Parameters
- valueTSource
- The enum value to be cast. 
- resultTObject
- The cast - value.
Returns
ToString()
Converts the UnmanagedEnumClass<TSource, TObject> instance to a human-readable string representation.
public override string ToString()Returns
- string
- A human-readable string representation of the UnmanagedEnumClass<TSource, TObject> instance. 
Operators
implicit operator TSource(UnmanagedEnumClass<TSource, TObject>)
Implicitly converts the UnmanagedEnumClass<TSource, TObject> to TSource.
public static implicit operator TSource(UnmanagedEnumClass<TSource, TObject> value)Parameters
- valueUnmanagedEnumClass<TSource, TObject>
- The value to convert. 
Returns
- TSource
implicit operator TObject(UnmanagedEnumClass<TSource, TObject>)
Implicitly converts the UnmanagedEnumClass<TSource, TObject> to TObject.
public static implicit operator TObject(UnmanagedEnumClass<TSource, TObject> value)Parameters
- valueUnmanagedEnumClass<TSource, TObject>
- The value to convert. 
Returns
- TObject
implicit operator UnmanagedEnumClass<TSource, TObject>(TSource)
Implicitly converts the TSource to EnumClass<TSource, TObject>.
public static implicit operator UnmanagedEnumClass<TSource, TObject>(TSource value)Parameters
- valueTSource
- The value to convert. 
Returns
- UnmanagedEnumClass<TSource, TObject>