Ejemplo n.º 1
0
        public static AccessType GetAccessType(string actionName, out ActionTypePattern pattern)
        {
            if (IsMatch(OtherActionPatterns, actionName, out pattern))
            {
                return AccessType.Custom;
            }
            if (IsMatch(DeleteActionPatterns, actionName, out pattern))
            {
                return AccessType.Delete;
            }
            if (IsMatch(CreateActionPatterns, actionName, out pattern))
            {
                return AccessType.Create;
            }
            if (IsMatch(UpdateActionPatterns, actionName, out pattern))
            {
                return AccessType.Update;
            }
            if (!IsMatch(ReadActionPatterns, actionName, out pattern))
            {
                pattern = new ActionTypePattern(ActionTypePattern.MatchAllFn, ActionTypePattern.GetSameActionGroupName);
            }

            return AccessType.Read;
        }
Ejemplo n.º 2
0
        public static bool IsMatch(List<ActionTypePattern> patterns, string actionName, out ActionTypePattern matchedPattern)
        {
            var result = from p in patterns
                             where p.IsMatchFn(actionName, p.Keyword)
                             select p;

            foreach (var pattern in result)
            {
                matchedPattern = pattern;
                return true;
            }
            matchedPattern = null;

            return false;
        }