/// <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); }
/// <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); }
public void GivenIHaveANewConfigurationObject() { _configuration = new AttributeRoutingConfiguration(); _configuration.InlineRouteConstraints.Add("color", typeof(EnumRouteConstraint <Color>)); _httpConfiguration = new HttpWebAttributeRoutingConfiguration(); _httpConfiguration.InlineRouteConstraints.Add("color", typeof(EnumRouteConstraint <Color>)); }
/// <summary> /// Route used by the AttributeRouting framework in web projects. /// </summary> public AttributeRoute(string url, RouteValueDictionary defaults, RouteValueDictionary constraints, RouteValueDictionary dataTokens, AttributeRoutingConfiguration configuration) : base(url, defaults, constraints, dataTokens, configuration.RouteHandlerFactory()) { _configuration = configuration; }
public RouteBuilder(AttributeRoutingConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException("configuration"); } _configuration = configuration; }
public void Returns_specified_url_for_area_url_when_both_subdomain_is_specified_and_area_url_is_specified() { var configuration = new AttributeRoutingConfiguration(); configuration.AddRoutesFromController<SubdomainWithAreaUrlController>(); var reflector = new RouteReflector(configuration); var specs = reflector.GenerateRouteSpecifications().ToList(); Assert.That(specs.Count, Is.EqualTo(1)); Assert.That(specs.Single().Subdomain, Is.EqualTo("private")); Assert.That(specs.Single().AreaUrl, Is.EqualTo("admin")); }
public void Returns_null_for_area_url_when_subdomain_is_specified_and_area_url_is_not_specified() { var configuration = new AttributeRoutingConfiguration(); configuration.AddRoutesFromController<SubdomainController>(); var reflector = new RouteReflector(configuration); var specs = reflector.BuildRouteSpecifications().ToList(); Assert.That(specs.Count, Is.EqualTo(1)); Assert.That(specs.Single().Subdomain, Is.EqualTo("users")); Assert.That(specs.Single().AreaUrl, Is.Null); }
public void Returns_specified_url_for_area_url_when_both_subdomain_is_specified_and_area_url_is_specified() { var configuration = new AttributeRoutingConfiguration(); configuration.AddRoutesFromController <SubdomainWithAreaUrlController>(); var reflector = new RouteReflector(configuration); var specs = reflector.GenerateRouteSpecifications().ToList(); Assert.That(specs.Count, Is.EqualTo(1)); Assert.That(specs.Single().Subdomain, Is.EqualTo("private")); Assert.That(specs.Single().AreaUrl, Is.EqualTo("admin")); }
public void Returns_null_for_area_url_when_subdomain_is_specified_and_area_url_is_not_specified() { var configuration = new AttributeRoutingConfiguration(); configuration.AddRoutesFromController <SubdomainController>(); var reflector = new RouteReflector(configuration); var specs = reflector.BuildRouteSpecifications().ToList(); Assert.That(specs.Count, Is.EqualTo(1)); Assert.That(specs.Single().Subdomain, Is.EqualTo("users")); Assert.That(specs.Single().AreaUrl, Is.Null); }
private AttributeRoute BuildAttributeRoute(string url, bool useLowercaseRoutes, bool appendTrailingSlash) { var configuration = new AttributeRoutingConfiguration { UseLowercaseRoutes = useLowercaseRoutes, AppendTrailingSlash = appendTrailingSlash, }; return(new AttributeRoute(url, new RouteValueDictionary(), new RouteValueDictionary(), new RouteValueDictionary(), configuration)); }
public void Returns_null_area_url_when_controller_configured_with_subdomain_only_via_configuration_object() { var configuration = new AttributeRoutingConfiguration(); configuration.AddRoutesFromController<SubdomainControllerWithoutSubdomainInAttribute>(); configuration.MapArea("NoSubdomain").ToSubdomain("subdomain"); var reflector = new RouteReflector(configuration); var specs = reflector.GenerateRouteSpecifications().ToList(); var spec = specs.SingleOrDefault(); Assert.That(spec, Is.Not.Null); Assert.That(spec.Subdomain, Is.EqualTo("subdomain")); Assert.That(spec.AreaName, Is.EqualTo("NoSubdomain")); Assert.That(spec.AreaUrl, Is.EqualTo(null)); }
public void Returns_subdomain_specified_for_area_via_configuration_object() { var configuration = new AttributeRoutingConfiguration(); configuration.AddRoutesFromController<SubdomainController>(); configuration.MapArea("Users").ToSubdomain("override"); var reflector = new RouteReflector(configuration); var specs = reflector.GenerateRouteSpecifications().ToList(); var spec = specs.SingleOrDefault(); Assert.That(spec, Is.Not.Null); Assert.That(spec.Subdomain, Is.EqualTo("override")); Assert.That(spec.AreaName, Is.EqualTo("Users")); Assert.That(spec.AreaUrl, Is.EqualTo(null)); }
public void Returns_null_area_url_when_controller_configured_with_subdomain_only_via_configuration_object() { var configuration = new AttributeRoutingConfiguration(); configuration.AddRoutesFromController <SubdomainControllerWithoutSubdomainInAttribute>(); configuration.MapArea("NoSubdomain").ToSubdomain("subdomain"); var reflector = new RouteReflector(configuration); var specs = reflector.GenerateRouteSpecifications().ToList(); var spec = specs.SingleOrDefault(); Assert.That(spec, Is.Not.Null); Assert.That(spec.Subdomain, Is.EqualTo("subdomain")); Assert.That(spec.AreaName, Is.EqualTo("NoSubdomain")); Assert.That(spec.AreaUrl, Is.EqualTo(null)); }
public void Returns_subdomain_specified_for_area_via_configuration_object() { var configuration = new AttributeRoutingConfiguration(); configuration.AddRoutesFromController <SubdomainController>(); configuration.MapArea("Users").ToSubdomain("override"); var reflector = new RouteReflector(configuration); var specs = reflector.GenerateRouteSpecifications().ToList(); var spec = specs.SingleOrDefault(); Assert.That(spec, Is.Not.Null); Assert.That(spec.Subdomain, Is.EqualTo("override")); Assert.That(spec.AreaName, Is.EqualTo("Users")); Assert.That(spec.AreaUrl, Is.EqualTo(null)); }
private Route BuildAttributeRoute(string url, bool useLowercaseRoutes, bool appendTrailingSlash) { var configuration = new AttributeRoutingConfiguration { UseLowercaseRoutes = useLowercaseRoutes, AppendTrailingSlash = appendTrailingSlash, }; return new AttributeRoute(url, new RouteValueDictionary(), new RouteValueDictionary(), new RouteValueDictionary(), configuration); }
public RouteBuilder(AttributeRoutingConfiguration configuration) { if (configuration == null) throw new ArgumentNullException("configuration"); _configuration = configuration; }
public RouteConstraintFactory(AttributeRoutingConfiguration configuration) { _configuration = configuration; }
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)); }
/// <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); }
public RouteConstraintFactory(AttributeRoutingConfiguration configuration) : base(configuration) { }
/// <summary> /// Helper for configuring areas when initializing AttributeRouting framework. /// </summary> public AreaConfiguration(string name, AttributeRoutingConfiguration configuration) { _name = name; _configuration = configuration; }
public AttributeRouteFactory(AttributeRoutingConfiguration configuration) { _configuration = configuration; }
public void GivenIHaveANewConfigurationObject() { _configuration = new AttributeRoutingConfiguration(); _httpConfiguration = new HttpAttributeRoutingConfiguration(); }
public void GivenIHaveANewConfigurationObject() { _configuration = new AttributeRoutingConfiguration(); _configuration.InlineRouteConstraints.Add("color", typeof(EnumRouteConstraint<Color>)); _httpConfiguration = new HttpWebAttributeRoutingConfiguration(); _httpConfiguration.InlineRouteConstraints.Add("color", typeof(EnumRouteConstraint<Color>)); }
public void GivenIHaveANewConfigurationObject() { _configuration = new AttributeRoutingConfiguration(); }