Ejemplo n.º 1
0
        public PropertyAllowed Merge(PropertyRoute key, Lite <RoleEntity> role, IEnumerable <KeyValuePair <Lite <RoleEntity>, PropertyAllowed> > baseValues)
        {
            PropertyAllowed best = AuthLogic.GetMergeStrategy(role) == MergeStrategy.Union ?
                                   Max(baseValues.Select(a => a.Value)) :
                                   Min(baseValues.Select(a => a.Value));

            if (!BasicPermission.AutomaticUpgradeOfProperties.IsAuthorized(role))
            {
                return(best);
            }

            var maxUp = PropertyAuthLogic.MaxAutomaticUpgrade.TryGetS(key);

            if (maxUp.HasValue && maxUp <= best)
            {
                return(best);
            }

            if (baseValues.Where(a => a.Value.Equals(best)).All(a => GetDefault(key, a.Key).Equals(a.Value)))
            {
                var def = GetDefault(key, role);

                return(maxUp.HasValue && maxUp <= def ? maxUp.Value : def);
            }

            return(best);
        }
Ejemplo n.º 2
0
 public bool Merge(PermissionSymbol key, Lite <RoleEntity> role, IEnumerable <KeyValuePair <Lite <RoleEntity>, bool> > baseValues)
 {
     if (AuthLogic.GetMergeStrategy(role) == MergeStrategy.Union)
     {
         return(baseValues.Any(a => a.Value));
     }
     else
     {
         return(baseValues.All(a => a.Value));
     }
 }
Ejemplo n.º 3
0
        public PropertyAllowed Merge(PropertyRoute key, Lite <RoleEntity> role, IEnumerable <KeyValuePair <Lite <RoleEntity>, PropertyAllowed> > baseValues)
        {
            PropertyAllowed best = AuthLogic.GetMergeStrategy(role) == MergeStrategy.Union ?
                                   Max(baseValues.Select(a => a.Value)) :
                                   Min(baseValues.Select(a => a.Value));

            if (!BasicPermission.AutomaticUpgradeOfProperties.IsAuthorized(role) || PropertyAuthLogic.AvoidAutomaticUpgradeCollection.Contains(key))
            {
                return(best);
            }

            if (baseValues.Where(a => a.Value.Equals(best)).All(a => GetDefault(key, a.Key).Equals(a.Value)))
            {
                return(GetDefault(key, role));
            }

            return(best);
        }