/// <summary> /// Initializes a new instance of the <see cref="ODataRouteMapping"/> class. /// </summary> /// <param name="route">The mapped <see cref="ODataRoute">OData route</see>.</param> /// <param name="apiVersion">The <see cref="ApiVersion">API version</see> associated with the route.</param> /// <param name="services">The <see cref="IServiceProvider">services</see> associated with the route.</param> public ODataRouteMapping(ODataRoute route, ApiVersion apiVersion, IServiceProvider services) { Arg.NotNull(route, nameof(route)); Arg.NotNull(apiVersion, nameof(apiVersion)); Arg.NotNull(services, nameof(services)); Route = route; ApiVersion = apiVersion; Services = services; }
internal ODataRouteBuilderContext( HttpConfiguration configuration, ApiVersion apiVersion, ODataRoute route, HttpActionDescriptor actionDescriptor, IList <ApiParameterDescription> parameterDescriptions, ModelTypeBuilder modelTypeBuilder, ODataApiExplorerOptions options) { Contract.Requires(configuration != null); Contract.Requires(apiVersion != null); Contract.Requires(route != null); Contract.Requires(actionDescriptor != null); Contract.Requires(parameterDescriptions != null); Contract.Requires(modelTypeBuilder != null); Contract.Requires(options != null); ApiVersion = apiVersion; serviceProvider = configuration.GetODataRootContainer(route); EdmModel = serviceProvider.GetRequiredService <IEdmModel>(); Assemblies = configuration.Services.GetAssembliesResolver().GetAssemblies(); routeAttribute = actionDescriptor.GetCustomAttributes <ODataRouteAttribute>().FirstOrDefault(); RouteTemplate = routeAttribute?.PathTemplate; Route = route; ActionDescriptor = actionDescriptor; ParameterDescriptions = parameterDescriptions; Options = options; UrlKeyDelimiter = configuration.GetUrlKeyDelimiter() ?? Parentheses; var container = EdmModel.EntityContainer; if (container == null) { IsRouteExcluded = true; return; } EntitySet = container.FindEntitySet(actionDescriptor.ControllerDescriptor.ControllerName); Operation = container.FindOperationImports(actionDescriptor.ActionName).FirstOrDefault()?.Operation ?? EdmModel.FindDeclaredOperations(container.Namespace + "." + actionDescriptor.ActionName).FirstOrDefault(); ActionType = GetActionType(EntitySet, Operation); if (Operation?.IsAction() == true) { ConvertODataActionParametersToTypedModel(modelTypeBuilder, (IEdmAction)Operation); } }
internal ODataRouteBuilderContext( HttpConfiguration configuration, ApiVersion apiVersion, ODataRoute route, HttpActionDescriptor actionDescriptor, IList <ApiParameterDescription> parameterDescriptions, IModelTypeBuilder modelTypeBuilder, ODataApiExplorerOptions options) { this.route = route; ApiVersion = apiVersion; Services = configuration.GetODataRootContainer(route); routeAttribute = actionDescriptor.GetCustomAttributes <ODataRouteAttribute>().FirstOrDefault(); RouteTemplate = routeAttribute?.PathTemplate; RoutePrefix = route.RoutePrefix?.Trim('/'); ActionDescriptor = actionDescriptor; ParameterDescriptions = parameterDescriptions; Options = options; UrlKeyDelimiter = UrlKeyDelimiterOrDefault(configuration.GetUrlKeyDelimiter() ?? Services.GetService <IODataPathHandler>()?.UrlKeyDelimiter); var selector = Services.GetRequiredService <IEdmModelSelector>(); var model = selector.SelectModel(apiVersion); var container = model?.EntityContainer; if (model == null || container == null) { EdmModel = Services.GetRequiredService <IEdmModel>(); IsRouteExcluded = true; return; } var controllerName = actionDescriptor.ControllerDescriptor.ControllerName; EdmModel = model; Services = new FixedEdmModelServiceProviderDecorator(Services, model); EntitySet = container.FindEntitySet(controllerName); Singleton = container.FindSingleton(controllerName); Operation = ResolveOperation(container, actionDescriptor.ActionName); ActionType = GetActionType(actionDescriptor); IsRouteExcluded = ActionType == ODataRouteActionType.Unknown; if (Operation?.IsAction() == true) { ConvertODataActionParametersToTypedModel(modelTypeBuilder, (IEdmAction)Operation, controllerName); } }
/// <summary> /// Initializes a new instance of the <see cref="ODataRouteMapping"/> class. /// </summary> /// <param name="route">The mapped <see cref="ODataRoute">OData route</see>.</param> /// <param name="apiVersion">The <see cref="ApiVersion">API version</see> associated with the route.</param> /// <param name="services">The <see cref="IServiceProvider">services</see> associated with the route.</param> public ODataRouteMapping(ODataRoute route, ApiVersion apiVersion, IServiceProvider services) { Route = route; ApiVersion = apiVersion; Services = services; }