예제 #1
0
 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;
     }
 }
예제 #2
0
 public static void SetEnum <T>(this T obj, MyJSON.JsonStruct input)
 {
     obj = SetEnum <T>(input);
 }