Enumerator

Ecng.Common

Provides extension methods and utilities for enum types.

メソッド

ExcludeNonBrowsable``1
public static IEnumerable<T> ExcludeNonBrowsable<T>(IEnumerable<T> values)
result = Enumerator.ExcludeNonBrowsable(values)

Excludes non-browsable enum values from the collection.

values
The collection of enum values.

戻り値: An enumerable of browsable enum values.

ExcludeObsolete``1
public static IEnumerable<T> ExcludeObsolete<T>(IEnumerable<T> values)
result = Enumerator.ExcludeObsolete(values)

Excludes obsolete enum values from the provided collection.

values
The collection of enum values.

戻り値: An enumerable without obsolete enum values.

GetAttributeOfType``1
public static TAttribute GetAttributeOfType<TAttribute>(object enumVal)
result = Enumerator.GetAttributeOfType(enumVal)

Retrieves an attribute of type TAttribute from the enum field value.

enumVal
The enum value.

戻り値: The attribute instance if found; otherwise, null.

GetEnumBaseType
public static Type GetEnumBaseType(Type enumType)
result = Enumerator.GetEnumBaseType(enumType)

Gets the underlying type of the specified enum type.

enumType
The enum type.

戻り値: The underlying numeric type for the enum.

GetEnumBaseType``1
public static Type GetEnumBaseType<T>()
result = Enumerator.GetEnumBaseType()

Gets the underlying base type of the enum type T.

戻り値: The underlying numeric type for the enum.

GetName
public static string GetName(Enum value)
result = Enumerator.GetName(value)

Gets the name of the enum value.

value
The enum value.

戻り値: The name of the enum value.

GetNames
public static IEnumerable<string> GetNames(Type enumType)
result = Enumerator.GetNames(enumType)

Gets all names of the specified enum type.

enumType
The enum type.

戻り値: An enumerable of enum names.

GetNames``1
public static IEnumerable<string> GetNames<T>()
result = Enumerator.GetNames()

Gets all names of the enum type T as a collection of strings.

戻り値: An enumerable of enum names.

GetName``1
public static string GetName<T>(T value)
result = Enumerator.GetName(value)

Gets the name of the specified enum value.

value
The enum value.

戻り値: The name of the enum value.

GetValues
public static IEnumerable<object> GetValues(Type enumType)
result = Enumerator.GetValues(enumType)

Gets all enum values for the specified enum type as objects.

enumType
The enum type.

戻り値: An enumerable of enum values as objects.

GetValues``1
public static IEnumerable<T> GetValues<T>()
result = Enumerator.GetValues()

Gets all enum values of type T.

戻り値: An enumerable of all enum values.

HasFlags``1
public static bool HasFlags<T>(T enumSource, T enumPart)
result = Enumerator.HasFlags(enumSource, enumPart)

Determines whether the specified enum value has the given flag(s).

enumSource
The source enum value.
enumPart
The flag(s) to check for.

戻り値: true if the flag(s) are present; otherwise, false.

IsDefined``1
public static bool IsDefined<T>(T enumValue)
result = Enumerator.IsDefined(enumValue)

Determines whether the specified enum value is defined in its type.

enumValue
The enum value.

戻り値: true if the value is defined; otherwise, false.

IsEnumBrowsable
public static bool IsEnumBrowsable(object enumVal)
result = Enumerator.IsEnumBrowsable(enumVal)

Determines whether the enum value is marked as browsable.

enumVal
The enum value.

戻り値: true if the enum value is browsable; otherwise, false.

IsFlags
public static bool IsFlags(Type enumType)
result = Enumerator.IsFlags(enumType)

Determines whether the specified enum type has the Flags attribute.

enumType
The enum type.

戻り値: true if the Flags attribute is present; otherwise, false.

JoinMask``1
public static T JoinMask<T>(IEnumerable<T> values)
result = Enumerator.JoinMask(values)

Joins the provided collection of enum values into a single masked enum value.

values
An enumerable of enum values.

戻り値: The resulting joined masked enum value.

JoinMask``1
public static T JoinMask<T>()
result = Enumerator.JoinMask()

Joins all flags of type T into a single masked enum value.

戻り値: The joined masked enum value.

Remove``1
public static T Remove<T>(T enumSource, T enumPart)
result = Enumerator.Remove(enumSource, enumPart)

Removes the specified flag(s) from the source enum value and returns the result.

enumSource
The source enum value.
enumPart
The flag(s) to remove.

戻り値: The enum value after removal of the specified flag(s).

Remove``1
public static T Remove<T>(Enum enumSource, T enumPart)
result = Enumerator.Remove(enumSource, enumPart)

Removes the specified flag from the enum value.

enumSource
The source enum value.
enumPart
The flag to remove.

戻り値: The enum value after removal of the flag.

SplitMask2
public static IEnumerable<object> SplitMask2(object maskedValue)
result = Enumerator.SplitMask2(maskedValue)

Splits the masked enum value into its constituent flag values and returns them as objects.

maskedValue
The masked enum value.

戻り値: An enumerable of individual flag values as objects.

SplitMask``1
public static IEnumerable<T> SplitMask<T>(T maskedValue)
result = Enumerator.SplitMask(maskedValue)

Splits the masked enum value into its constituent flag values of type T.

maskedValue
The masked enum value.

戻り値: An enumerable of individual flag values of type T.

TryParse``1
public static bool TryParse<T>(string str, T value, bool ignoreCase)
result = Enumerator.TryParse(str, value, ignoreCase)

Attempts to parse the string to an enum value of type T.

str
The string representation of the enum value.
value
When this method returns, contains the enum value equivalent to the string, if the parse succeeded.
ignoreCase
if set to true ignores case during parsing.

戻り値: true if the parse was successful; otherwise, false.