示例#1
0
        private void FillRemovePrivilege(PrivilegeDepthExtended initialValue
                                         , PrivilegeDepthExtended currentValue
                                         , PrivilegeType privilegeType
                                         , HashSet <Guid> privilegesRemove
                                         )
        {
            if (currentValue == initialValue)
            {
                return;
            }

            if (privilegeType == PrivilegeType.None ||
                EntityPrivileges == null ||
                !EntityPrivileges.Any()
                )
            {
                return;
            }

            var privilege = EntityPrivileges.FirstOrDefault(p => p.PrivilegeType == privilegeType);

            if (privilege == null)
            {
                return;
            }

            if (currentValue == PrivilegeDepthExtended.None)
            {
                privilegesRemove.Add(privilege.PrivilegeId);
            }
        }
示例#2
0
        private void FillAddPrivilege(PrivilegeDepthExtended initialValue
                                      , PrivilegeDepthExtended currentValue
                                      , PrivilegeType privilegeType
                                      , Dictionary <Guid, PrivilegeDepth> privilegesAdd
                                      )
        {
            if (currentValue == initialValue)
            {
                return;
            }

            if (privilegeType == PrivilegeType.None ||
                EntityPrivileges == null ||
                !EntityPrivileges.Any()
                )
            {
                return;
            }

            var privilege = EntityPrivileges.FirstOrDefault(p => p.PrivilegeType == privilegeType);

            if (privilege == null)
            {
                return;
            }

            if (currentValue != PrivilegeDepthExtended.None)
            {
                if (privilegesAdd.ContainsKey(privilege.PrivilegeId))
                {
                    privilegesAdd[privilege.PrivilegeId] = (PrivilegeDepth)Math.Max((int)currentValue, (int)privilegesAdd[privilege.PrivilegeId]);
                }
                else
                {
                    privilegesAdd.Add(privilege.PrivilegeId, (PrivilegeDepth)currentValue);
                }
            }
        }