예제 #1
0
        public void AddPermission <T>(TRightId rightId, AccessType access, Func <T, TSession, bool> conditionFunc = null, Func <TSession, Expression <Func <T, bool> > > conditionCreateExpression = null)
        {
            if (!rightPermissions.TryGetValue(rightId, out var rp))
            {
                rightPermissions.Add(rightId, rp = new RightPermissions <TSession>());
            }

            rp.AddPermission(access, conditionFunc, conditionCreateExpression);
        }
예제 #2
0
 public void AddPermissions(RightPermissions <TSession> p)
 {
     foreach (var tp in p.typePermissions)
     {
         if (typePermissions.TryGetValue(tp.Key, out var currentTp))
         {
             currentTp.AddPermissions(tp.Value);
         }
         else
         {
             typePermissions.Add(tp.Key, tp.Value.Clone());
         }
     }
 }
예제 #3
0
        private static RightPermissions <TSession> Merge(RightPermissions <TSession>[] all)
        {
            if (all.Length == 0)
            {
                return(null);
            }
            if (all.Length == 1)
            {
                return(all[0]);
            }

            var p = new RightPermissions <TSession>();

            foreach (var rp in all)
            {
                p.AddPermissions(rp);
            }
            return(p);
        }