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); }
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()); } } }
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); }