コード例 #1
0
        /// <summary>
        /// Scans the specified assemblies for all routes defined with AttributeRouting attributes,
        /// and applies configuration options against the routes found.
        /// </summary>
        /// <param name="routes"> </param>
        /// <param name="configurationAction">The initialization action that builds the configuration object</param>
        public static void MapAttributeRoutes(this RouteCollection routes, Action <AttributeRoutingConfiguration> configurationAction)
        {
            var configuration = new AttributeRoutingConfiguration();

            configurationAction.Invoke(configuration);

            routes.MapAttributeRoutesInternal(configuration);
        }
コード例 #2
0
        /// <summary>
        /// Scans the calling assembly for all routes defined with AttributeRouting attributes,
        /// using the default conventions.
        /// </summary>
        public static void MapAttributeRoutes(this RouteCollection routes)
        {
            var configuration = new AttributeRoutingConfiguration();

            configuration.AddRoutesFromAssembly(Assembly.GetCallingAssembly());

            routes.MapAttributeRoutesInternal(configuration);
        }
コード例 #3
0
        private static void MapAttributeRoutesInternal(this RouteCollection routes, AttributeRoutingConfiguration configuration)
        {
            var generatedRoutes = new RouteBuilder(configuration).BuildAllRoutes();

            generatedRoutes.ToList().ForEach(r => routes.Add(r.RouteName, (AttributeRoute)r));
        }
コード例 #4
0
 /// <summary>
 /// Scans the specified assemblies for all routes defined with AttributeRouting attributes,
 /// and applies configuration options against the routes found.
 /// </summary>
 /// <param name="routes"></param>
 /// <param name="configuration">The configuration object</param>
 public static void MapAttributeRoutes(this RouteCollection routes, AttributeRoutingConfiguration configuration)
 {
     routes.MapAttributeRoutesInternal(configuration);
 }