Class EnumClass<TSource, TObject>
A class which allows System.Enum implicit conversions.
Can be used along with System.Enum, means it doesn't require another EnumClass<TSource, TObject> instance to be comparable or usable.
Inheritance
Implements
Inherited Members
Namespace: Exiled.API.Features.Core.Generic
Assembly: Exiled.API.dll
Syntax
public abstract class EnumClass<TSource, TObject> : IComparable, IEquatable<TObject>, IComparable<TObject>, IComparer<TObject> where TSource : Enum where TObject : EnumClass<TSource, TObject>
Type Parameters
| Name | Description |
|---|---|
| TSource | The type of the source object to handle the instance of. |
| TObject | The type of the child object to handle the instance of. |
Constructors
| Improve this Doc View SourceEnumClass(TSource)
Initializes a new instance of the EnumClass<TSource, TObject> class.
Declaration
protected EnumClass(TSource value)
Parameters
| Type | Name | Description |
|---|---|---|
| TSource | value | The value of the enum item. |
Properties
| Improve this Doc View SourceName
Gets the name determined from reflection.
Declaration
public string Name { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
Value
Gets the value of the enum item.
Declaration
public TSource Value { get; }
Property Value
| Type | Description |
|---|---|
| TSource |
Values
Gets all TObject object instances.
Declaration
public static IEnumerable<TObject> Values { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<TObject> |
Methods
| Improve this Doc View SourceCast(TSource)
Casts the specified value to the corresponding type.
Declaration
public static TObject Cast(TSource value)
Parameters
| Type | Name | Description |
|---|---|---|
| TSource | value | The enum value to be cast. |
Returns
| Type | Description |
|---|---|
| TObject | The cast object. |
Cast(IEnumerable<TSource>)
Casts the specified values to the corresponding type.
Declaration
public static IEnumerable<TObject> Cast(IEnumerable<TSource> values)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<TSource> | values | The enum values to be cast. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<TObject> | The cast object. |
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.
Declaration
public int Compare(TObject x, TObject y)
Parameters
| Type | Name | Description |
|---|---|---|
| TObject | x | An object to compare. |
| TObject | y | Another object to compare. |
Returns
| Type | Description |
|---|---|
| System.Int32 | 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.
Declaration
public int CompareTo(TObject other)
Parameters
| Type | Name | Description |
|---|---|---|
| TObject | other | An object to compare with this instance. |
Returns
| Type | Description |
|---|---|
| System.Int32 | 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.
Declaration
public int CompareTo(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | obj | An object to compare with this instance. |
Returns
| Type | Description |
|---|---|
| System.Int32 | 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(TObject)
Determines whether the specified object is equal to the current object.
Declaration
public bool Equals(TObject other)
Parameters
| Type | Name | Description |
|---|---|---|
| TObject | other | The object to compare. |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if the object was equal; otherwise, false. |
Equals(Object)
Determines whether the specified object is equal to the current object.
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | obj | The object to compare. |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if the object was equal; otherwise, false. |
Overrides
GetHashCode()
Returns a the 32-bit signed hash code of the current object instance.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| System.Int32 | The 32-bit signed hash code of the current object instance. |
Overrides
GetValues(Type)
Retrieves an array of the values of the constants in a specified EnumClass<TSource, TObject>.
Declaration
public static TSource[] GetValues(Type type)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | type | The EnumClass<TSource, TObject> type. |
Returns
| Type | Description |
|---|---|
| TSource[] | An array of the values of the constants in a specified EnumClass<TSource, TObject>. |
Parse(String)
Parses a System.String object.
Declaration
public static TObject Parse(string obj)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | obj | The object to be parsed. |
Returns
| Type | Description |
|---|---|
| TObject | The corresponding |
SafeCast(TSource, out TObject)
Safely casts the specified value to the corresponding type.
Declaration
public static bool SafeCast(TSource value, out TObject result)
Parameters
| Type | Name | Description |
|---|---|---|
| TSource | value | The enum value to be cast. |
| TObject | result | The cast |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if the |
SafeCast(IEnumerable<TSource>, out IEnumerable<TObject>)
Safely casts the specified values to the corresponding type.
Declaration
public static bool SafeCast(IEnumerable<TSource> values, out IEnumerable<TObject> results)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<TSource> | values | The enum value to be cast. |
| System.Collections.Generic.IEnumerable<TObject> | results | The cast |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if the |
ToString()
Converts the EnumClass<TSource, TObject> instance to a human-readable System.String representation.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| System.String | A human-readable System.String representation of the EnumClass<TSource, TObject> instance. |
Overrides
Operators
| Improve this Doc View SourceImplicit(TSource to EnumClass<TSource, TObject>)
Implicitly converts the TSource to EnumClass<TSource, TObject>.
Declaration
public static implicit operator EnumClass<TSource, TObject>(TSource value)
Parameters
| Type | Name | Description |
|---|---|---|
| TSource | value | The value to convert. |
Returns
| Type | Description |
|---|---|
| EnumClass<TSource, TObject> |
Implicit(EnumClass<TSource, TObject> to TSource)
Implicitly converts the EnumClass<TSource, TObject> to TSource.
Declaration
public static implicit operator TSource(EnumClass<TSource, TObject> value)
Parameters
| Type | Name | Description |
|---|---|---|
| EnumClass<TSource, TObject> | value | The value to convert. |
Returns
| Type | Description |
|---|---|
| TSource |
Implicit(EnumClass<TSource, TObject> to TObject)
Implicitly converts the EnumClass<TSource, TObject> to TObject.
Declaration
public static implicit operator TObject(EnumClass<TSource, TObject> value)
Parameters
| Type | Name | Description |
|---|---|---|
| EnumClass<TSource, TObject> | value | The value to convert. |
Returns
| Type | Description |
|---|---|
| TObject |