Exemplo n.º 1
0
 public static bool IsFlagsSet(ObjectAccessId accessObject, RightsFlags[] flags,SetType setType=SetType.Any)
 {
     if (LoggedUser == null)
         throw new Exception("Invalid user!");
     if (LoggedUser.IsAdmin)
         return true;
     switch (setType)
     {
         case SetType.All:
             if (flags.Select(flag => IsFlagSet(accessObject, flag)).All(result => result))
             {
                 return true;
             }
             break;
         case SetType.Any:
             if (flags.Select(flag => IsFlagSet(accessObject, flag)).Any(result => result))
             {
                 return true;
             }
             break;
         default:
             throw new ArgumentOutOfRangeException("setType");
     }
     return false;
 }