public PermissionGroup addPermissionsFromGroup(PermissionGroup total, Group group) {
     Type t = total.GetType();
     foreach (FieldInfo f in t.GetFields()) {
         if (f.FieldType.Equals(true.GetType())) {
             bool cur = (bool)f.GetValue(total);
             cur = cur || ((bool)group.GetType().GetProperty(f.Name).GetGetMethod().Invoke(group, null));
             f.SetValue(total, cur);
         }
     }
     return total;
 }
예제 #2
0
        public PermissionGroup addPermissionsFromGroup(PermissionGroup total, Group group)
        {
            Type t = total.GetType();

            foreach (FieldInfo f in t.GetFields())
            {
                if (f.FieldType.Equals(true.GetType()))
                {
                    bool cur = (bool)f.GetValue(total);
                    cur = cur || ((bool)group.GetType().GetProperty(f.Name).GetGetMethod().Invoke(group, null));
                    f.SetValue(total, cur);
                }
            }
            return(total);
        }
        public bool getPermission(string name)
        {
            PermissionGroup pg = this.getPermissionGroup(new PermissionGroup());

            return((bool)pg.GetType().GetField(name).GetValue(pg));
        }
 /// <summary>
 /// Populate the given permission group with this user's permissions
 /// </summary>
 /// <param name="db">DB Context</param>
 /// <param name="pg">The permission group to populate</param>
 /// <returns>The passed-in permission group with this user's permissions</returns>
 public PermissionGroup getPermissionGroup(PermissionGroup pg)
 {
     return(this.UserGroups.Where(a => a.validated).Select(a => a.Group)
            .Aggregate(pg, pg.addPermissionsFromGroup));
 }