Beispiel #1
0
 public static bool IsSecure(this CommandCode commandCode)
 {
     using (var locker = doubleCheckLock.Accquire(
                () => secureHashSet.Contains(commandCode)))
     {
         if (locker.Locked)
         {
             var newSet   = new HashSet <CommandCode>();
             var enumType = commandCode.GetType();
             foreach (var val in Enum.GetValues(enumType))
             {
                 var field = enumType.GetField(val.ToString());
                 if (Attribute.IsDefined(field, typeof(SecureAttribute)))
                 {
                     newSet.Add((CommandCode)Enum.Parse(
                                    typeof(CommandCode), val.ToString()));
                 }
             }
             secureHashSet = newSet;
         }
         return(secureHashSet.Contains(commandCode));
     }
 }