Example #1
0
    public static PermissionRulePack GetPermissionRules(Lite <RoleEntity> roleLite)
    {
        var result = new PermissionRulePack {
            Role = roleLite
        };

        cache.GetRules(result, SymbolLogic <PermissionSymbol> .Symbols);
        return(result);
    }
        public static OperationRulePack GetOperationRules(Lite <RoleEntity> role, TypeEntity typeEntity)
        {
            var resources = OperationLogic.GetAllOperationInfos(TypeLogic.EntityToType[typeEntity]).Select(a => a.OperationSymbol);
            var result    = new OperationRulePack {
                Role = role, Type = typeEntity,
            };

            cache.GetRules(result, resources);

            var coercer = OperationCoercer.Instance.GetCoerceValue(role);

            result.Rules.ForEach(r => r.CoercedValues = EnumExtensions.GetValues <OperationAllowed>().Where(a => !coercer(r.Resource, a).Equals(a)).ToArray());

            return(result);
        }
Example #3
0
        public static PropertyRulePack GetPropertyRules(Lite <RoleEntity> role, TypeEntity typeEntity)
        {
            var result = new PropertyRulePack {
                Role = role, Type = typeEntity
            };

            cache.GetRules(result, PropertyRouteLogic.RetrieveOrGenerateProperties(typeEntity));

            var coercer = PropertyCoercer.Instance.GetCoerceValue(role);

            result.Rules.ForEach(r => r.CoercedValues = EnumExtensions.GetValues <PropertyAllowed>()
                                                        .Where(a => !coercer(PropertyRouteEntity.ToPropertyRouteFunc(r.Resource), a).Equals(a))
                                                        .ToArray());

            return(result);
        }
Example #4
0
        public static QueryRulePack GetQueryRules(Lite <RoleEntity> role, TypeEntity typeEntity)
        {
            var result = new QueryRulePack {
                Role = role, Type = typeEntity
            };

            cache.GetRules(result, QueryLogic.GetTypeQueries(typeEntity));

            var coercer = QueryCoercer.Instance.GetCoerceValue(role);

            result.Rules.ForEach(r => r.CoercedValues = EnumExtensions.GetValues <QueryAllowed>()
                                                        .Where(a => !coercer(QueryLogic.ToQueryName(r.Resource.Key), a).Equals(a))
                                                        .ToArray());

            return(result);
        }