public static T SetEnum <T>(MyJSON.JsonStruct input) { try { return((T)Enum.Parse(typeof(T), (string)input.Value)); } catch (ArgumentException argex) { Console.WriteLine("ArgumentException: " + argex.Message); Console.WriteLine("The key \"" + input.ParentName + "\" can only have these values below:"); Console.WriteLine(string.Join("\n", Enum.GetNames(typeof(T)))); throw; } }
public static void SetEnum <T>(this T obj, MyJSON.JsonStruct input) { obj = SetEnum <T>(input); }