예제 #1
0
        internal static void ValidateRouteEntry(RouteEntry entry)
        {
            Contract.Assert(entry != null);

            TRoute route = entry.Route;

            Contract.Assert(route != null);

            TActionDescriptor[] targetActions = route.GetTargetActionDescriptors();

            if (targetActions == null || targetActions.Length == 0)
            {
                throw new InvalidOperationException(
                          TResources.DirectRoute_MissingActionDescriptors
                          );
            }
#if ASPNETWEBAPI
            if (route.Handler != null)
            {
                throw new InvalidOperationException(TResources.DirectRoute_HandlerNotSupported);
            }
#else
            if (route.RouteHandler != null)
            {
                throw new InvalidOperationException(
                          TResources.DirectRoute_RouteHandlerNotSupported
                          );
            }
#endif
        }
예제 #2
0
        /// <summary>Initializes a new instance of the <see cref="RouteEntry"/> class.</summary>
        /// <param name="name">The route name, if any; otherwise, <see langword="null"/>.</param>
        /// <param name="route">The route.</param>
        public RouteEntry(string name, TRoute route)
        {
            if (route == null)
            {
                throw new ArgumentNullException("route");
            }

            _name  = name;
            _route = route;
        }
예제 #3
0
        /// <summary>Initializes a new instance of the <see cref="RouteEntry"/> class.</summary>
        /// <param name="name">The route name, if any; otherwise, <see langword="null"/>.</param>
        /// <param name="route">The route.</param>
        public RouteEntry(string name, TRoute route)
        {
            if (route == null)
            {
                throw new ArgumentNullException("route");
            }

            _name = name;
            _route = route;
        }
        public static LocalizationRoute ToLocalizationRoute(this TIRoute route, string url, string culture)
        {
            // Add culture to the route defaults so it can be used as action parameter
            TRouteValueDictionary defaults = new TRouteValueDictionary(route.Defaults);

            defaults["culture"] = culture;

            return(new LocalizationRoute(url, defaults,
                                         new TRouteValueDictionary(route.Constraints), new TRouteValueDictionary(route.DataTokens), route.RouteHandler(),
                                         culture));
        }
 public bool Match(HttpRequestMessage request, System.Web.Http.Routing.IHttpRoute route, string parameterName, IDictionary <string, object> values, System.Web.Http.Routing.HttpRouteDirection routeDirection)
 {
     if (routeDirection == System.Web.Http.Routing.HttpRouteDirection.UriResolution)
     {
         string version = GetApiKey(request) ?? DefaultApiKey;
         if (!AllowedHeaderKeys.Contains(version))
         {
             throw new Core.Exceptions.Profile.InvalidApiKeyException("Invalid API Key Detected");
         }
     }
     return(true);
 }
 public static string Url(this TIRoute route)
 {
     return(route.Url);
 }
 public static IRouteHandler RouteHandler(this TIRoute route)
 {
     return(route.RouteHandler);
 }
 public static string Url(this TIRoute route)
 {
     return(route.RouteTemplate);
 }
 public static HttpMessageHandler RouteHandler(this TIRoute route)
 {
     return(route.Handler);
 }