23 lines
658 B
C#
23 lines
658 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace xCommons.Extensions {
|
|
public static partial class EnumExtensions {
|
|
public static string GetKey (this Enum source) {
|
|
return Enum.GetName (source.GetType (), source);
|
|
}
|
|
|
|
public static T GetValue<T> (this string source) {
|
|
return (T) Enum.Parse (typeof (T), source);
|
|
}
|
|
|
|
public static void Iterate<T> (this IEnumerator<T> source, Action<T> action) {
|
|
//
|
|
while (source.MoveNext ()) {
|
|
//
|
|
var current = source.Current;
|
|
action (current);
|
|
}
|
|
}
|
|
}
|
|
} |