/// <summary> /// Initializes a new instance of the <see cref="AttributeRoutingConvention"/> class. /// </summary> /// <param name="model">The <see cref="IEdmModel"/> to be used for parsing the route templates.</param> /// <param name="configuration">The <see cref="HttpConfiguration"/> to use for figuring out all the controllers to /// look for a match.</param> /// <param name="pathTemplateHandler">The path template handler to be used for parsing the path templates.</param> public AttributeRoutingConvention(IEdmModel model, HttpConfiguration configuration, IODataPathTemplateHandler pathTemplateHandler) : this(model, pathTemplateHandler) { if (configuration == null) { throw Error.ArgumentNull("configuration"); } DefaultODataPathHandler odataPathHanlder = pathTemplateHandler as DefaultODataPathHandler; if (odataPathHanlder != null) { odataPathHanlder.ResolverSetttings = configuration.GetResolverSettings(); } Action<HttpConfiguration> oldInitializer = configuration.Initializer; bool initialized = false; configuration.Initializer = (config) => { if (!initialized) { initialized = true; oldInitializer(config); IHttpControllerSelector controllerSelector = config.Services.GetHttpControllerSelector(); _attributeMappings = BuildAttributeMappings(controllerSelector.GetControllerMapping().Values); } }; }
/// <summary> /// Initializes a new instance of the <see cref="AttributeRoutingConvention"/> class. /// </summary> /// <param name="model">The <see cref="IEdmModel"/> to be used for parsing the route templates.</param> /// <param name="controllers">The collection of controllers to search for a match.</param> /// <param name="pathTemplateHandler">The path template handler to be used for parsing the path templates.</param> public AttributeRoutingConvention(IEdmModel model, IEnumerable <HttpControllerDescriptor> controllers, IODataPathTemplateHandler pathTemplateHandler) : this(model, pathTemplateHandler) { if (controllers == null) { throw Error.ArgumentNull("controllers"); } _attributeMappingsFunc = () => BuildAttributeMappings(controllers); }
/// <summary> /// Initializes a new instance of the <see cref="VersionedAttributeRoutingConvention"/> class. /// </summary> /// <param name="routeName">The name of the route.</param> /// <param name="controllers">The <see cref="IEnumerable{T}">sequence</see> of <see cref="HttpControllerDescriptor">controller descriptors</see> /// associated with the routing convention.</param> /// <param name="pathTemplateHandler">The <see cref="IODataPathTemplateHandler">OData path template handler</see> associated with the routing convention.</param> /// <param name="apiVersion">The <see cref="ApiVersion">API version</see> associated with the convention.</param> public VersionedAttributeRoutingConvention(string routeName, IEnumerable <HttpControllerDescriptor> controllers, IODataPathTemplateHandler pathTemplateHandler, ApiVersion apiVersion) { if (controllers == null) { throw new ArgumentNullException(nameof(controllers)); } this.routeName = routeName; ODataPathTemplateHandler = pathTemplateHandler; ApiVersion = apiVersion; attributeMappings = BuildAttributeMappings(controllers); }
private AttributeRoutingConvention CreateAttributeRoutingConvention( string routeName, HttpConfiguration configuration, IODataPathTemplateHandler pathTemplateHandler = null) { if (pathTemplateHandler == null) { return(new AttributeRoutingConvention(routeName: routeName, configuration: configuration)); } return(new AttributeRoutingConvention(routeName: routeName, configuration: configuration, pathTemplateHandler: pathTemplateHandler)); }
/// <summary> /// Initializes a new instance of the <see cref="VersionedAttributeRoutingConvention"/> class. /// </summary> /// <param name="routeName">The name of the route.</param> /// <param name="controllers">The <see cref="IEnumerable{T}">sequence</see> of <see cref="HttpControllerDescriptor">controller descriptors</see> /// associated with the routing convention.</param> /// <param name="pathTemplateHandler">The <see cref="IODataPathTemplateHandler">OData path template handler</see> associated with the routing convention.</param> /// <param name="apiVersion">The <see cref="ApiVersion">API version</see> associated with the convention.</param> public VersionedAttributeRoutingConvention(string routeName, IEnumerable <HttpControllerDescriptor> controllers, IODataPathTemplateHandler pathTemplateHandler, ApiVersion apiVersion) { Arg.NotNull(routeName, nameof(routeName)); Arg.NotNull(controllers, nameof(controllers)); Arg.NotNull(pathTemplateHandler, nameof(pathTemplateHandler)); Arg.NotNull(apiVersion, nameof(apiVersion)); this.routeName = routeName; ODataPathTemplateHandler = pathTemplateHandler; ApiVersion = apiVersion; attributeMappings = BuildAttributeMappings(controllers); }
private AttributeRoutingConvention CreateAttributeRoutingConvention( string routeName, IRouteBuilder routeBuilder, IODataPathTemplateHandler pathTemplateHandler = null) { if (pathTemplateHandler == null) { return(new AttributeRoutingConvention(routeName: routeName, serviceProvider: routeBuilder.ServiceProvider)); } return(new AttributeRoutingConvention(routeName: routeName, serviceProvider: routeBuilder.ServiceProvider, pathTemplateHandler: pathTemplateHandler)); }
/// <summary> /// Initializes a new instance of the <see cref="AttributeRoutingConvention"/> class. /// </summary> /// <param name="model">The <see cref="IEdmModel"/> to be used for parsing the route templates.</param> /// <param name="controllers">The collection of controllers to search for a match.</param> /// <param name="pathTemplateHandler">The path template handler to be used for parsing the path templates.</param> public AttributeRoutingConvention(IEdmModel model, IEnumerable<HttpControllerDescriptor> controllers, IODataPathTemplateHandler pathTemplateHandler) : this(model, pathTemplateHandler) { if (controllers == null) { throw Error.ArgumentNull("controllers"); } _attributeMappingsFunc = () => BuildAttributeMappings(controllers); }
public AttributeRoutingConvention(string routeName, IEnumerable <HttpControllerDescriptor> controllers, IODataPathTemplateHandler pathTemplateHandler) : this(routeName, pathTemplateHandler) { if (controllers == null) { throw Error.ArgumentNull("controllers"); } _attributeMappings = BuildAttributeMappings(controllers); }
private AttributeRoutingConvention(IEdmModel model, IODataPathTemplateHandler pathTemplateHandler) { if (model == null) { throw Error.ArgumentNull("model"); } if (pathTemplateHandler == null) { throw Error.ArgumentNull("pathTemplateHandler"); } Model = model; ODataPathTemplateHandler = pathTemplateHandler; }
/// <summary> /// Initializes a new instance of the <see cref="AttributeRoutingConvention"/> class. /// </summary> /// <param name="pathTemplateHandler"></param> /// <param name="actionCollectionProvider"></param> public AttributeRoutingConvention(IODataPathTemplateHandler pathTemplateHandler, IActionDescriptorCollectionProvider actionCollectionProvider) { if (pathTemplateHandler == null) { throw Error.ArgumentNull("pathTemplateHandler"); } if (actionCollectionProvider == null) { throw Error.ArgumentNull("actionCollectionProvider"); } ODataPathTemplateHandler = pathTemplateHandler; ActionDescriptorCollectionProvider = actionCollectionProvider; }
private AttributeRoutingConvention(string routeName, IODataPathTemplateHandler pathTemplateHandler) { if (routeName == null) { throw Error.ArgumentNull("routeName"); } if (pathTemplateHandler == null) { throw Error.ArgumentNull("pathTemplateHandler"); } _routeName = routeName; ODataPathTemplateHandler = pathTemplateHandler; }
internal static ODataPathTemplate?SafeParseTemplate( this IODataPathTemplateHandler handler, string pathTemplate, IServiceProvider serviceProvider) { try { return(handler.ParseTemplate(pathTemplate, serviceProvider)); } catch (ODataException) { // this 'should' mean the controller does not map to the current edm model. there's no way to know this without // forcing a developer to explicitly map it. while it could be a mistake, simply yield null. this results in the // template being skipped and will ultimately result in a 4xx if requested, which is acceptable. return(default);
/// <summary> /// Initializes a new instance of the <see cref="VersionedAttributeRoutingConvention"/> class. /// </summary> /// <param name="routeName">The name of the route.</param> /// <param name="configuration">The current <see cref="HttpConfiguration">HTTP configuration</see>.</param> /// <param name="pathTemplateHandler">The <see cref="IODataPathTemplateHandler">OData path template handler</see> associated with the routing convention.</param> public VersionedAttributeRoutingConvention(string routeName, HttpConfiguration configuration, IODataPathTemplateHandler pathTemplateHandler) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } RouteName = routeName; ODataPathTemplateHandler = pathTemplateHandler; if (pathTemplateHandler is IODataPathHandler pathHandler && pathHandler.UrlKeyDelimiter == null) { var urlKeyDelimiter = configuration.GetUrlKeyDelimiter(); pathHandler.UrlKeyDelimiter = urlKeyDelimiter; } }
/// <summary> /// Initializes a new instance of the <see cref="VersionedAttributeRoutingConvention"/> class. /// </summary> /// <param name="routeName">The name of the route.</param> /// <param name="serviceProvider">The current <see cref="IServiceProvider">HTTP configuration</see>.</param> /// <param name="pathTemplateHandler">The <see cref="IODataPathTemplateHandler">OData path template handler</see> associated with the routing convention.</param> /// <param name="apiVersion">The <see cref="ApiVersion">API version</see> associated with the convention.</param> public VersionedAttributeRoutingConvention(string routeName, IServiceProvider serviceProvider, IODataPathTemplateHandler pathTemplateHandler, ApiVersion apiVersion) { Arg.NotNull(routeName, nameof(routeName)); Arg.NotNull(serviceProvider, nameof(serviceProvider)); Arg.NotNull(apiVersion, nameof(apiVersion)); this.routeName = routeName; this.serviceProvider = serviceProvider; ApiVersion = apiVersion; if ((ODataPathTemplateHandler = pathTemplateHandler) == null) { var perRouteContainer = serviceProvider.GetRequiredService <IPerRouteContainer>(); var rootContainer = perRouteContainer.GetODataRootContainer(routeName); ODataPathTemplateHandler = rootContainer.GetRequiredService <IODataPathTemplateHandler>(); } }
/// <summary> /// Initializes a new instance of the <see cref="AttributeRoutingConvention"/> class. /// </summary> /// <param name="model">The <see cref="IEdmModel"/> to be used for parsing the route templates.</param> /// <param name="configuration">The <see cref="HttpConfiguration"/> to use for figuring out all the controllers to /// look for a match.</param> /// <param name="pathTemplateHandler">The path template handler to be used for parsing the path templates.</param> public AttributeRoutingConvention(IEdmModel model, HttpConfiguration configuration, IODataPathTemplateHandler pathTemplateHandler) : this(model, pathTemplateHandler) { if (configuration == null) { throw Error.ArgumentNull("configuration"); } Action<HttpConfiguration> oldInitializer = configuration.Initializer; configuration.Initializer = (config) => { oldInitializer(config); IHttpControllerSelector controllerSelector = config.Services.GetHttpControllerSelector(); _attributeMappingsFunc = () => BuildAttributeMappings(controllerSelector.GetControllerMapping().Values); }; }
/// <summary> /// Initializes a new instance of the <see cref="AttributeRoutingConvention"/> class. /// </summary> /// <param name="model">The <see cref="IEdmModel"/> to be used for parsing the route templates.</param> /// <param name="configuration">The <see cref="HttpConfiguration"/> to use for figuring out all the controllers to /// look for a match.</param> /// <param name="pathTemplateHandler">The path template handler to be used for parsing the path templates.</param> public AttributeRoutingConvention(IEdmModel model, HttpConfiguration configuration, IODataPathTemplateHandler pathTemplateHandler) : this(model, pathTemplateHandler) { if (configuration == null) { throw Error.ArgumentNull("configuration"); } Action <HttpConfiguration> oldInitializer = configuration.Initializer; configuration.Initializer = (config) => { oldInitializer(config); IHttpControllerSelector controllerSelector = config.Services.GetHttpControllerSelector(); _attributeMappingsFunc = () => BuildAttributeMappings(controllerSelector.GetControllerMapping().Values); }; }
internal AttributeRoutingConvention(string routeName, IEnumerable <ControllerActionDescriptor> controllers, IODataPathTemplateHandler pathTemplateHandler) : this(routeName) { if (controllers == null) { throw Error.ArgumentNull("controllers"); } if (pathTemplateHandler == null) { throw Error.ArgumentNull("pathTemplateHandler"); } ODataPathTemplateHandler = pathTemplateHandler; // Look for a service provider on the ControllerActionDescriptor, which the unit test will setup // so the BuildAttributeMappings can find the perRouteContainer. _serviceProvider = controllers.FirstOrDefault()?.Properties["serviceProvider"] as IServiceProvider; _attributeMappings = BuildAttributeMappings(controllers); }
/// <summary> /// Initializes a new instance of the <see cref="AttributeRoutingConvention"/> class. /// </summary> /// <param name="routeName">The name of the route.</param> /// <param name="configuration">The <see cref="HttpConfiguration"/> to use for figuring out all the controllers to /// look for a match.</param> /// <param name="pathTemplateHandler">The path template handler to be used for parsing the path templates.</param> /// <remarks>This signature uses types that are AspNet-specific.</remarks> public AttributeRoutingConvention(string routeName, HttpConfiguration configuration, IODataPathTemplateHandler pathTemplateHandler) : this(routeName) { if (configuration == null) { throw Error.ArgumentNull("configuration"); } if (pathTemplateHandler == null) { throw Error.ArgumentNull("pathTemplateHandler"); } ODataPathTemplateHandler = pathTemplateHandler; // if settings is not on local, use the global configuration settings. IODataPathHandler pathHandler = pathTemplateHandler as IODataPathHandler; if (pathHandler != null && pathHandler.UrlKeyDelimiter == null) { ODataUrlKeyDelimiter urlKeyDelimiter = configuration.GetUrlKeyDelimiter(); pathHandler.UrlKeyDelimiter = urlKeyDelimiter; } Action <HttpConfiguration> oldInitializer = configuration.Initializer; bool initialized = false; configuration.Initializer = (config) => { if (!initialized) { initialized = true; oldInitializer(config); IHttpControllerSelector controllerSelector = config.Services.GetHttpControllerSelector(); _attributeMappings = BuildAttributeMappings(controllerSelector.GetControllerMapping().Values); } }; }
public static ODataPathTemplate ParseTemplate(this IODataPathTemplateHandler handler, IEdmModel model, string odataPathTemplate) { Contract.Assert(handler != null); return(handler.ParseTemplate(odataPathTemplate, new MockContainer(model))); }
/// <summary> /// Initializes a new instance of the <see cref="VersionedAttributeRoutingConvention"/> class. /// </summary> /// <param name="routeName">The name of the route.</param> /// <param name="controllers">The <see cref="IEnumerable{T}">sequence</see> of <see cref="HttpControllerDescriptor">controller descriptors</see> /// associated with the routing convention.</param> /// <param name="pathTemplateHandler">The <see cref="IODataPathTemplateHandler">OData path template handler</see> associated with the routing convention.</param> /// <param name="apiVersion">The <see cref="ApiVersion">API version</see> associated with the convention.</param> public VersionedAttributeRoutingConvention(string routeName, IEnumerable <HttpControllerDescriptor> controllers, IODataPathTemplateHandler pathTemplateHandler, ApiVersion apiVersion) : base(routeName, controllers, pathTemplateHandler) { Arg.NotNull(apiVersion, nameof(apiVersion)); this.apiVersion = apiVersion; }
/// <summary> /// Initializes a new instance of the <see cref="VersionedAttributeRoutingConvention"/> class. /// </summary> /// <param name="routeName">The name of the route.</param> /// <param name="configuration">The current <see cref="HttpConfiguration">HTTP configuration</see>.</param> /// <param name="pathTemplateHandler">The <see cref="IODataPathTemplateHandler">OData path template handler</see> associated with the routing convention.</param> /// <param name="apiVersion">The <see cref="ApiVersion">API version</see> associated with the convention.</param> public VersionedAttributeRoutingConvention(string routeName, HttpConfiguration configuration, IODataPathTemplateHandler pathTemplateHandler, ApiVersion apiVersion) : base(routeName, configuration, pathTemplateHandler) { Arg.NotNull(apiVersion, nameof(apiVersion)); this.apiVersion = apiVersion; }
private AttributeRoutingConvention(IEdmModel model, IODataPathTemplateHandler pathTemplateHandler) { if (model == null) { throw Error.ArgumentNull("model"); } if (pathTemplateHandler == null) { throw Error.ArgumentNull("pathTemplateHandler"); } Model = model; ODataPathTemplateHandler = pathTemplateHandler; }
public MyAttributeRoutingConvention(IEdmModel model, HttpConfiguration configuration, IODataPathTemplateHandler pathTemplateHandler) : base(model, configuration, pathTemplateHandler) { }
public MyAttributeRoutingConvention(IEdmModel model, IEnumerable<HttpControllerDescriptor> controllers, IODataPathTemplateHandler pathTemplateHandler) : base(model, controllers, pathTemplateHandler) { }
public MyAttributeRoutingConvention(string routeName, IEnumerable<HttpControllerDescriptor> controllers, IODataPathTemplateHandler pathTemplateHandler) : base(routeName, controllers, pathTemplateHandler) { }
public MyAttributeRoutingConvention(string routeName, HttpConfiguration configuration, IODataPathTemplateHandler pathTemplateHandler) : base(routeName, configuration, pathTemplateHandler) { }
/// <summary> /// Initializes a new instance of the <see cref="VersionedAttributeRoutingConvention"/> class. /// </summary> /// <param name="routeName">The name of the route.</param> /// <param name="serviceProvider">The current <see cref="IServiceProvider">HTTP configuration</see>.</param> /// <param name="pathTemplateHandler">The <see cref="IODataPathTemplateHandler">OData path template handler</see> associated with the routing convention.</param> /// <param name="apiVersion">The <see cref="ApiVersion">API version</see> associated with the convention.</param> public VersionedAttributeRoutingConvention(string routeName, IServiceProvider serviceProvider, IODataPathTemplateHandler pathTemplateHandler, ApiVersion apiVersion) { this.routeName = routeName; this.serviceProvider = serviceProvider; ApiVersion = apiVersion; ODataPathTemplateHandler = pathTemplateHandler; }
public MyAttributeRoutingConvention(string routeName, HttpConfiguration configuration, IODataPathTemplateHandler pathTemplateHandler) : base(routeName, configuration, pathTemplateHandler) { }
public MyAttributeRoutingConvention(IEdmModel model, HttpConfiguration configuration, IODataPathTemplateHandler pathTemplateHandler) : base(model, configuration, pathTemplateHandler) { }
public MyAttributeRoutingConvention(string routeName, IEnumerable<HttpControllerDescriptor> controllers, IODataPathTemplateHandler pathTemplateHandler) : base(routeName, controllers, pathTemplateHandler) { }
/// <summary> /// Initializes a new instance of the <see cref="VersionedAttributeRoutingConvention"/> class. /// </summary> /// <param name="routeName">The name of the route.</param> /// <param name="configuration">The current <see cref="HttpConfiguration">HTTP configuration</see>.</param> /// <param name="pathTemplateHandler">The <see cref="IODataPathTemplateHandler">OData path template handler</see> associated with the routing convention.</param> /// <param name="apiVersion">The <see cref="ApiVersion">API version</see> associated with the convention.</param> public VersionedAttributeRoutingConvention(string routeName, HttpConfiguration configuration, IODataPathTemplateHandler pathTemplateHandler, ApiVersion apiVersion) { Arg.NotNull(routeName, nameof(routeName)); Arg.NotNull(configuration, nameof(configuration)); Arg.NotNull(pathTemplateHandler, nameof(pathTemplateHandler)); Arg.NotNull(apiVersion, nameof(apiVersion)); this.routeName = routeName; ODataPathTemplateHandler = pathTemplateHandler; ApiVersion = apiVersion; if (pathTemplateHandler is IODataPathHandler pathHandler && pathHandler.UrlKeyDelimiter == null) { var urlKeyDelimiter = configuration.GetUrlKeyDelimiter(); pathHandler.UrlKeyDelimiter = urlKeyDelimiter; } var initialized = false; var initializer = configuration.Initializer; configuration.Initializer = config => { if (initialized) { return; } initialized = true; initializer?.Invoke(config); var controllerSelector = configuration.Services.GetHttpControllerSelector(); attributeMappings = BuildAttributeMappings(controllerSelector.GetControllerMapping().Values); }; }
public MyAttributeRoutingConvention(IEdmModel model, IEnumerable <HttpControllerDescriptor> controllers, IODataPathTemplateHandler pathTemplateHandler) : base(model, controllers, pathTemplateHandler) { }