Example #1
0
        private PathPart[] ExtractPathParts(MethodParameter[] methodParameters, RouteAttribute routeAttribute)
        {
            PathPart[] result = null;

            if (!String.IsNullOrEmpty(routeAttribute.Route))
            {
                var unescaped = OwinConvert.UrlDecode(routeAttribute.Route);
                result = unescaped
                         .Split('/')
                         .Select(r => PathPart.Create(r, methodParameters))
                         .ToArray();
            }

            return(result);
        }
Example #2
0
        /// <summary>
        /// Creates a new object.
        /// </summary>
        /// <param name="controllerType"></param>
        /// <param name="method"></param>
        /// <param name="routeAttribute"></param>
        public Route(ControllerType controllerType, MethodInfo method, RouteAttribute routeAttribute) : this()
        {
            ControllerType = controllerType;
            Method         = method;
            RouteAttribute = routeAttribute;

            FilterAttributes           = BuildFilterAttributes(controllerType, method);
            AuthorizationFilters       = FilterAttributes.OfType <IAuthorizationFilter>().ToArray();
            OtherFilters               = BuildOtherFilters(FilterAttributes, AuthorizationFilters);
            HasAllowAnonymousAttribute = method.GetCustomAttributes <AllowAnonymousAttribute>(inherit: false).Any();
            TypeParserResolver         = BuildTypeParserResolver(controllerType, method);
            TypeFormatterResolver      = BuildTypeFormatterResolver(controllerType, method);
            MethodParameters           = ExtractMethodParameters(method, TypeParserResolver);
            HttpMethod = ExtractHttpMethod(method);
            PathParts  = ExtractPathParts(MethodParameters, routeAttribute);

            ValidatePathParts();

            ID = Interlocked.Increment(ref _NextID);
        }