Example #1
0
 public static T Toggle <T>(this System.Enum type, T value)
 {
     try
     {
         if (type.Has(value))
         {
             return(type.Add(value));
         }
         else
         {
             return(type.Remove(value));
         }
     }
     catch (Exception ex)
     {
         throw new ArgumentException(
                   string.Format(
                       "Could not toggle value from enumerated type '{0}'.",
                       typeof(T).Name
                       ), ex);
     }
 }