コード例 #1
0
ファイル: Global.asax.cs プロジェクト: ruscal/myMoodServer
 public static void RegisterWebApiRoutes(System.Web.Http.HttpRouteCollection routes)
 {
     routes.MapHttpRoute(
         name: "ApiAction",
         routeTemplate: "api/{controller}/{action}",
         defaults: new { action = "Get" }
         );
 }
コード例 #2
0
        public static void ConfigureApiGenerator(System.Web.Http.HttpRouteCollection routes, GeneratorConfig configuration)
        {
            GeneratorConfig.CheckGeneratorConfig(configuration);

            routes.MapHttpRoute(
                name: "CodeGenerator",
                routeTemplate: String.IsNullOrEmpty(configuration.RouteTemplate) ? "C/G/API/{action}" : configuration.RouteTemplate,
                defaults: null,
                constraints: null,
                handler: new GeneratorHandler(configuration)
                );
        }
コード例 #3
0
 /// <summary>
 /// Ignores the specified route.
 /// </summary>
 /// <param name="routes">A collection of routes for the application.</param>
 /// <param name="routeName">The name of the route to ignore.</param>
 /// <param name="routeTemplate">The route template for the route.</param>
 public static IHttpRoute IgnoreRoute(this HttpRouteCollection routes, string routeName, string routeTemplate)
 {
     return(IgnoreRoute(routes, routeName, routeTemplate, constraints: null));
 }
コード例 #4
0
 /// <summary>
 /// Maps the specified OData route.
 /// </summary>
 /// <param name="routes">A collection of routes for the application.</param>
 /// <param name="routeName">The name of the route to map.</param>
 /// <param name="routePrefix">The prefix to add to the OData route's path template.</param>
 /// <param name="model">The EDM model to use for parsing OData paths.</param>
 /// <param name="pathHandler">The <see cref="IODataPathHandler"/> to use for parsing the OData path.</param>
 /// <param name="routingConventions">The OData routing conventions to use for controller and action selection.</param>
 public static void MapODataRoute(this HttpRouteCollection routes, string routeName, string routePrefix, IEdmModel model,
                                  IODataPathHandler pathHandler, IEnumerable <IODataRoutingConvention> routingConventions)
 {
     routes.MapODataRoute(routeName, routePrefix, model, pathHandler, routingConventions, batchHandler: null);
 }
コード例 #5
0
 /// <summary>
 /// Maps the specified OData route. When the <paramref name="batchHandler"/> is provided, it will create a '$batch' endpoint to handle the batch requests.
 /// </summary>
 /// <param name="routes">A collection of routes for the application.</param>
 /// <param name="routeName">The name of the route to map.</param>
 /// <param name="routePrefix">The prefix to add to the OData route's path template.</param>
 /// <param name="model">The EDM model to use for parsing OData paths.</param>
 /// <param name="batchHandler">The <see cref="ODataBatchHandler"/>.</param>
 public static void MapODataRoute(this HttpRouteCollection routes, string routeName, string routePrefix, IEdmModel model, ODataBatchHandler batchHandler)
 {
     routes.MapODataRoute(routeName, routePrefix, model, new DefaultODataPathHandler(), ODataRoutingConventions.CreateDefault(), batchHandler);
 }
コード例 #6
0
 /// <summary>
 /// Maps the specified OData route.
 /// </summary>
 /// <param name="routes">A collection of routes for the application.</param>
 /// <param name="routeName">The name of the route to map.</param>
 /// <param name="routePrefix">The prefix to add to the OData route's path template.</param>
 /// <param name="model">The EDM model to use for parsing OData paths.</param>
 public static void MapODataRoute(this HttpRouteCollection routes, string routeName, string routePrefix, IEdmModel model)
 {
     routes.MapODataRoute(routeName, routePrefix, model, batchHandler: null);
 }
コード例 #7
0
 public static IHttpRoute MapHttpBatchRoute(this HttpRouteCollection routes, string routeName, string routeTemplate, HttpBatchHandler batchHandler)
 {
     return(routes.MapHttpRoute(routeName, routeTemplate, defaults: null, constraints: null, handler: batchHandler));
 }
コード例 #8
0
 /// <summary>
 /// Maps the specified route template and sets default route values and constraints.
 /// </summary>
 /// <param name="routes">A collection of routes for the application.</param>
 /// <param name="name">The name of the route to map.</param>
 /// <param name="routeTemplate">The route template for the route.</param>
 /// <param name="defaults">An object that contains default route values.</param>
 /// <param name="constraints">A set of expressions that specify values for <paramref name="routeTemplate"/>.</param>
 /// <returns>A reference to the mapped route.</returns>
 public static IHttpRoute MapHttpRoute(this HttpRouteCollection routes, string name, string routeTemplate, object defaults, object constraints)
 {
     return(MapHttpRoute(routes, name, routeTemplate, defaults, constraints, handler: null));
 }
 /// <summary>
 /// Maps the specified route template.
 /// </summary>
 /// <param name="routes">A collection of routes for the application.</param>
 /// <param name="name">The name of the route to map.</param>
 /// <param name="routeTemplate">The route template for the route.</param>
 /// <returns>A reference to the mapped route.</returns>
 public static IHttpRoute MapHttpRoute(this HttpRouteCollection routes, string name, string routeTemplate)
 {
     return(MapHttpRoute(routes, name, routeTemplate, defaults: null, constraints: null));
 }
コード例 #10
0
 public static void MapODataRoute(this HttpRouteCollection routes, string routeName, string routePrefix,
                                  IEdmModel model, IODataPathHandler pathHandler, IEnumerable <IODataRoutingConvention> routingConventions)
 {
     Extensions.HttpRouteCollectionExtensions.MapODataServiceRoute(routes, routeName, routePrefix, model,
                                                                   pathHandler, routingConventions);
 }
コード例 #11
0
 public static void MapODataRoute(this HttpRouteCollection routes, string routeName, string routePrefix,
                                  IEdmModel model, ODataBatchHandler batchHandler)
 {
     Extensions.HttpRouteCollectionExtensions.MapODataServiceRoute(routes, routeName, routePrefix, model, batchHandler);
 }
コード例 #12
0
 // Add generation hooks for the Attribute-routing subroutes.
 // This lets us generate urls for routes supplied by attr-based routing.
 private static void AddGenerationHooksForSubRoutes(HttpRouteCollection destRoutes, HttpRouteCollection sourceRoutes)
 {
     foreach (KeyValuePair <string, IHttpRoute> kv in sourceRoutes.GetRoutesWithNames())
     {
         string     name      = kv.Key;
         IHttpRoute route     = kv.Value;
         var        stubRoute = new GenerateRoute(route);
         destRoutes.Add(name, stubRoute);
     }
 }
コード例 #13
0
        private static void AddRouteToRespondWithBadRequestWhenAtLeastOneRouteCouldMatch( string routeName, string routePrefix, HttpRouteCollection routes, List<ODataRoute> odataRoutes, List<IHttpRouteConstraint> unversionedConstraints )
        {
            Contract.Requires( !IsNullOrEmpty( routeName ) );
            Contract.Requires( routes != null );
            Contract.Requires( odataRoutes != null );
            Contract.Requires( unversionedConstraints != null );

            var unversionedRoute = new ODataRoute( routePrefix, new UnversionedODataPathRouteConstraint( unversionedConstraints ) );

            AddApiVersionConstraintIfNecessary( unversionedRoute );
            routes.Add( routeName + UnversionedRouteSuffix, unversionedRoute );
            odataRoutes.Add( unversionedRoute );
        }
コード例 #14
0
 // Normal route table enumeration doesn't include the route name.
 internal static IEnumerable <KeyValuePair <string, IHttpRoute> > GetRoutesWithNames(this HttpRouteCollection routes)
 {
     KeyValuePair <string, IHttpRoute>[] names = new KeyValuePair <string, IHttpRoute> [routes.Count];
     routes.CopyTo(names, 0);
     return(names);
 }
コード例 #15
0
 public static IHttpRoute MapHttpRoute(this HttpRouteCollection routes, string name, string routeTemplate, object defaults, string[] namespaces)
 {
     return(AfxRouteCollectionExtensions.MapHttpRoute(routes, name, routeTemplate, defaults,
                                                      null, null, namespaces));
 }