示例#1
0
        public IList <RoleBasedPermissionRule> TryGetRoleBasedPermissionRules(params string[] permissionIds)
        {
            var rules = new List <RoleBasedPermissionRule>();

            if (permissionIds == null)
            {
                return(rules);
            }

            foreach (var permissionId in permissionIds)
            {
                if (RoleBasedPermissionRules.TryGetValue(permissionId, out var theRule))
                {
                    rules.Add(theRule);
                }
            }
            return(rules);
        }
示例#2
0
 public void SetRoleBasedPermissionRules(IEnumerable <RoleBasedPermissionRule> rules, bool replaceExist = true)
 {
     if (rules == null)
     {
         return;
     }
     foreach (var rule in rules)
     {
         if (RoleBasedPermissionRules.TryGetValue(rule.PermissionId, out var theRule))
         {
             if (replaceExist)
             {
                 RoleBasedPermissionRules.AddOrUpdate(rule);
             }
         }
         else
         {
             RoleBasedPermissionRules.AddOrUpdate(rule);
         }
     }
 }