Initial Commit ...
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user