예제 #1
0
 public TestPathSetting(string path, PathMatchType matchType, bool ignoreCase, RequestSecurity security)
 {
     Path = path;
     MatchType = matchType;
     IgnoreCase = ignoreCase;
     Security = security;
 }
예제 #2
0
 public TestPathSetting(string path, PathMatchType matchType, bool ignoreCase, RequestSecurity security)
 {
     Path       = path;
     MatchType  = matchType;
     IgnoreCase = ignoreCase;
     Security   = security;
 }
예제 #3
0
            public PathMatch(string match)
            {
                this.match = match;

                if (this.match.EndsWith("/[*]", StringComparison.Ordinal))
                {
                    type       = PathMatchType.ArrayWildcard;
                    this.match = this.match.Substring(0, this.match.Length - 3);
                }
                else if (this.match.EndsWith("/*", StringComparison.Ordinal))
                {
                    type       = PathMatchType.ObjectWildcard;
                    this.match = this.match.Substring(0, this.match.Length - 1);
                }
                else
                {
                    type = PathMatchType.Literal;
                }
            }
예제 #4
0
        /// <summary>
        /// Creates an appropriate path matcher for the specified match type.
        /// </summary>
        /// <param name="matchType">The PathMatchType used to determine the appropriate path matcher.</param>
        /// <returns></returns>
        public static IPathMatcher Create(PathMatchType matchType)
        {
            // Check for cached matchers first.
            IDictionary <PathMatchType, IPathMatcher> cachedMatchers = CachedMatchers;

            if (cachedMatchers != null && cachedMatchers.ContainsKey(matchType))
            {
                IPathMatcher cachedPathMatcher = cachedMatchers[matchType];
                Logger.LogFormat("Cached {0} retrieved.", cachedPathMatcher.GetType().Name);
                return(cachedPathMatcher);
            }

            // Create the appropriate path matcher.
            IPathMatcher pathMatcher;

            switch (matchType)
            {
            case PathMatchType.Regex:
                pathMatcher = new RegexPathMatcher();
                break;

            case PathMatchType.StartsWith:
                pathMatcher = new StartsWithPathMatcher();
                break;

            case PathMatchType.Exact:
                pathMatcher = new ExactPathMatcher();
                break;

            default:
                throw new ArgumentOutOfRangeException("matchType");
            }

            // Cache the path matcher, if possible.
            if (cachedMatchers != null)
            {
                cachedMatchers.Add(matchType, pathMatcher);
            }

            Logger.LogFormat("Creating {0}.", pathMatcher.GetType().Name);
            return(pathMatcher);
        }
        /// <summary>
        /// Creates an appropriate path matcher for the specified match type.
        /// </summary>
        /// <param name="matchType">The PathMatchType used to determine the appropriate path matcher.</param>
        /// <returns></returns>
        public static IPathMatcher Create(PathMatchType matchType)
        {
            // Check for cached matchers first.
            IDictionary<PathMatchType, IPathMatcher> cachedMatchers = CachedMatchers;
            if (cachedMatchers != null && cachedMatchers.ContainsKey(matchType)) {
                IPathMatcher cachedPathMatcher = cachedMatchers[matchType];
                Logger.LogFormat("Cached {0} retrieved.", cachedPathMatcher.GetType().Name);
                return cachedPathMatcher;
            }

            // Create the appropriate path matcher.
            IPathMatcher pathMatcher;
            switch (matchType) {
                case PathMatchType.Regex:
                    pathMatcher = new RegexPathMatcher();
                    break;

                case PathMatchType.StartsWith:
                    pathMatcher = new StartsWithPathMatcher();
                    break;

                case PathMatchType.Exact:
                    pathMatcher = new ExactPathMatcher();
                    break;

                default:
                    throw new ArgumentOutOfRangeException("matchType");
            }

            // Cache the path matcher, if possible.
            if (cachedMatchers != null) {
                cachedMatchers.Add(matchType, pathMatcher);
            }

            Logger.LogFormat("Creating {0}.", pathMatcher.GetType().Name);
            return pathMatcher;
        }