diff --git a/src/Microsoft.Restier.Core/ApiBase.cs b/src/Microsoft.Restier.Core/ApiBase.cs index 3b50359f..a2b74469 100644 --- a/src/Microsoft.Restier.Core/ApiBase.cs +++ b/src/Microsoft.Restier.Core/ApiBase.cs @@ -21,13 +21,21 @@ namespace Microsoft.Restier.Core /// public abstract class ApiBase : IDisposable { - private static readonly ConcurrentDictionary Configurations = - new ConcurrentDictionary(); - private ApiConfiguration apiConfiguration; private ApiContext apiContext; private IServiceProvider serviceProvider; + /// + /// Initializes a new instance of the class. + /// + /// + /// An containing all services of this . + /// + protected ApiBase(IServiceProvider serviceProvider) + { + this.serviceProvider = serviceProvider; + } + /// /// Gets the which contains all services of this . /// @@ -37,12 +45,6 @@ public IServiceProvider ServiceProvider { return serviceProvider; } - - set - { - // TODO use set but not in constructor as need to update lots of test cases - this.serviceProvider = value; - } } /// @@ -72,7 +74,7 @@ public ApiContext Context public bool IsDisposed { get; private set; } /// - /// Gets or sets the API configuration for this API. + /// Gets the API configuration for this API. /// public ApiConfiguration Configuration { @@ -85,13 +87,6 @@ public ApiConfiguration Configuration return this.apiConfiguration; } - - set - { - // TODO keep now as lots of test cases need to update - this.apiConfiguration = value; - Configurations.TryAdd(GetType(), apiConfiguration); - } } /// @@ -137,13 +132,5 @@ public void Dispose() GC.SuppressFinalize(this); } - - // Registered as a scoped service so that IApi and ApiContext could be exposed as scoped service. - // If a descendant class wants to expose these 2 services in another way, it must ensure they could be - // resolved after CreateApiContext call. - internal class ApiHolder - { - public ApiBase Api { get; set; } - } } } diff --git a/src/Microsoft.Restier.Core/ApiConfiguration.cs b/src/Microsoft.Restier.Core/ApiConfiguration.cs index fad124c0..6cd200d2 100644 --- a/src/Microsoft.Restier.Core/ApiConfiguration.cs +++ b/src/Microsoft.Restier.Core/ApiConfiguration.cs @@ -30,29 +30,8 @@ public class ApiConfiguration private static Action emptyConfig = _ => { }; - private IServiceProvider serviceProvider; - private Task modelTask; - /// - /// Initializes a new instance of the class. - /// - /// - /// An containing all services of this . - /// - public ApiConfiguration(IServiceProvider serviceProvider) - { - this.serviceProvider = serviceProvider; - } - - /// - /// Gets the which contains all services of this . - /// - internal IServiceProvider ServiceProvider - { - get { return serviceProvider; } - } - internal IEdmModel Model { get; private set; } /// diff --git a/src/Microsoft.Restier.Core/ApiConfigurationExtensions.cs b/src/Microsoft.Restier.Core/ApiConfigurationExtensions.cs deleted file mode 100644 index a2c1f067..00000000 --- a/src/Microsoft.Restier.Core/ApiConfigurationExtensions.cs +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. - -using System; -using System.Collections.Generic; -using Microsoft.Extensions.DependencyInjection; - -namespace Microsoft.Restier.Core -{ - /// - /// Offers a collection of extension methods to . - /// - public static class ApiConfigurationExtensions - { - #region GetApiService - - /// - /// Gets a service instance. - /// - /// - /// An API configuration. - /// - /// The service type. - /// The service instance. - public static T GetApiService(this ApiConfiguration configuration) where T : class - { - Ensure.NotNull(configuration, "configuration"); - return configuration.ServiceProvider.GetService(); - } - - #endregion - - #region PropertyBag - - /// - /// Indicates if this object has a property. - /// - /// - /// An API configuration. - /// - /// - /// The name of a property. - /// - /// - /// true if this object has the - /// property; otherwise, false. - /// - public static bool HasProperty(this ApiConfiguration configuration, string name) - { - return configuration.GetPropertyBag().HasProperty(name); - } - - /// - /// Gets a property. - /// - /// - /// The type of the property. - /// - /// - /// An API configuration. - /// - /// - /// The name of a property. - /// - /// - /// The value of the property. - /// - public static T GetProperty(this ApiConfiguration configuration, string name) - { - return configuration.GetPropertyBag().GetProperty(name); - } - - /// - /// Gets a property. - /// - /// - /// An API configuration. - /// - /// - /// The name of a property. - /// - /// - /// The value of the property. - /// - public static object GetProperty(this ApiConfiguration configuration, string name) - { - return configuration.GetPropertyBag().GetProperty(name); - } - - /// - /// Sets a property. - /// - /// - /// An API configuration. - /// - /// - /// The name of a property. - /// - /// - /// A value for the property. - /// - public static void SetProperty(this ApiConfiguration configuration, string name, object value) - { - configuration.GetPropertyBag().SetProperty(name, value); - } - - /// - /// Clears a property. - /// - /// - /// An API configuration. - /// - /// - /// The name of a property. - /// - public static void ClearProperty(this ApiConfiguration configuration, string name) - { - configuration.GetPropertyBag().ClearProperty(name); - } - - #endregion - - #region PropertyBag Private - - private static PropertyBag GetPropertyBag(this ApiConfiguration configuration) - { - Ensure.NotNull(configuration, "configuration"); - return configuration.GetApiService(); - } - - #endregion - } -} \ No newline at end of file diff --git a/src/Microsoft.Restier.Core/ApiContext.cs b/src/Microsoft.Restier.Core/ApiContext.cs index f0bf0877..925e281b 100644 --- a/src/Microsoft.Restier.Core/ApiContext.cs +++ b/src/Microsoft.Restier.Core/ApiContext.cs @@ -19,12 +19,12 @@ public class ApiContext /// /// Initializes a new instance of the class. /// - /// - /// An API configuration. - /// /// /// The service provider. /// + /// + /// An API configuration. + /// public ApiContext(IServiceProvider provider, ApiConfiguration configuration) { Ensure.NotNull(configuration, "configuration"); diff --git a/src/Microsoft.Restier.Core/Microsoft.Restier.Core.csproj b/src/Microsoft.Restier.Core/Microsoft.Restier.Core.csproj index 99868f3d..b8b53ed8 100644 --- a/src/Microsoft.Restier.Core/Microsoft.Restier.Core.csproj +++ b/src/Microsoft.Restier.Core/Microsoft.Restier.Core.csproj @@ -27,7 +27,7 @@ ..\..\packages\Microsoft.OData.Core.7.0.0-beta\lib\portable-net45+win8+wpa81\Microsoft.OData.Core.dll - ..\..\packages\Microsoft.OData.Edm.7.0.0-beta\lib\portable-net45+win8+wpa81\Microsoft.OData.Edm.dll + ..\..\packages\Microsoft.OData.Edm.7.0.0\lib\portable-net45+win8+wpa81\Microsoft.OData.Edm.dll True @@ -73,7 +73,6 @@ - diff --git a/src/Microsoft.Restier.Core/packages.config b/src/Microsoft.Restier.Core/packages.config index 3918a147..fcc3a38f 100644 --- a/src/Microsoft.Restier.Core/packages.config +++ b/src/Microsoft.Restier.Core/packages.config @@ -2,7 +2,7 @@ - + diff --git a/src/Microsoft.Restier.Providers.EntityFramework/EntityFrameworkApi.cs b/src/Microsoft.Restier.Providers.EntityFramework/EntityFrameworkApi.cs index 46456252..f57d3b8f 100644 --- a/src/Microsoft.Restier.Providers.EntityFramework/EntityFrameworkApi.cs +++ b/src/Microsoft.Restier.Providers.EntityFramework/EntityFrameworkApi.cs @@ -30,6 +30,16 @@ namespace Microsoft.Restier.Providers.EntityFramework #endif public class EntityFrameworkApi : ApiBase where T : DbContext { + /// + /// Initializes a new instance of the class. + /// + /// + /// An containing all services of this . + /// + public EntityFrameworkApi(IServiceProvider serviceProvider) : base(serviceProvider) + { + } + /// /// Gets the underlying DbContext for this API. /// diff --git a/src/Microsoft.Restier.Providers.EntityFramework/Microsoft.Restier.Providers.EntityFramework.csproj b/src/Microsoft.Restier.Providers.EntityFramework/Microsoft.Restier.Providers.EntityFramework.csproj index f76ffbd0..f026b542 100644 --- a/src/Microsoft.Restier.Providers.EntityFramework/Microsoft.Restier.Providers.EntityFramework.csproj +++ b/src/Microsoft.Restier.Providers.EntityFramework/Microsoft.Restier.Providers.EntityFramework.csproj @@ -26,11 +26,11 @@ True - ..\..\packages\Microsoft.OData.Edm.7.0.0-beta\lib\portable-net45+win8+wpa81\Microsoft.OData.Edm.dll + ..\..\packages\Microsoft.OData.Edm.7.0.0\lib\portable-net45+win8+wpa81\Microsoft.OData.Edm.dll True - ..\..\packages\Microsoft.Spatial.7.0.0-beta\lib\portable-net45+win8+wpa81\Microsoft.Spatial.dll + ..\..\packages\Microsoft.Spatial.7.0.0\lib\portable-net45+win8+wpa81\Microsoft.Spatial.dll True diff --git a/src/Microsoft.Restier.Providers.EntityFramework/packages.config b/src/Microsoft.Restier.Providers.EntityFramework/packages.config index 1e4c077c..34f77b9e 100644 --- a/src/Microsoft.Restier.Providers.EntityFramework/packages.config +++ b/src/Microsoft.Restier.Providers.EntityFramework/packages.config @@ -2,8 +2,8 @@ - - + + diff --git a/src/Microsoft.Restier.Publishers.OData/Batch/RestierBatchChangeSetRequestItem.cs b/src/Microsoft.Restier.Publishers.OData/Batch/RestierBatchChangeSetRequestItem.cs index 47285fd9..8095c1c7 100644 --- a/src/Microsoft.Restier.Publishers.OData/Batch/RestierBatchChangeSetRequestItem.cs +++ b/src/Microsoft.Restier.Publishers.OData/Batch/RestierBatchChangeSetRequestItem.cs @@ -7,6 +7,8 @@ using System.Threading; using System.Threading.Tasks; using System.Web.OData.Batch; +using System.Web.OData.Extensions; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Restier.Core; using Microsoft.Restier.Core.Submit; @@ -17,19 +19,13 @@ namespace Microsoft.Restier.Publishers.OData.Batch /// public class RestierBatchChangeSetRequestItem : ChangeSetRequestItem { - private Func apiFactory; - /// /// Initializes a new instance of the class. /// /// The request messages. - /// Gets or sets the callback to create API. - public RestierBatchChangeSetRequestItem(IEnumerable requests, Func apiFactory) + public RestierBatchChangeSetRequestItem(IEnumerable requests) : base(requests) { - Ensure.NotNull(apiFactory, "apiFactory"); - - this.apiFactory = apiFactory; } /// @@ -89,9 +85,10 @@ public override async Task SendRequestAsync( return new ChangeSetResponseItem(responses); } - internal async Task SubmitChangeSet(ChangeSet changeSet) + internal async Task SubmitChangeSet(HttpRequestMessage request, ChangeSet changeSet) { - using (var api = this.apiFactory()) + var requestContainer = request.GetRequestContainer(); + using (var api = requestContainer.GetService()) { SubmitResult submitResults = await api.SubmitAsync(changeSet); } diff --git a/src/Microsoft.Restier.Publishers.OData/Batch/RestierBatchHandler.cs b/src/Microsoft.Restier.Publishers.OData/Batch/RestierBatchHandler.cs index a6e4d992..fdc543af 100644 --- a/src/Microsoft.Restier.Publishers.OData/Batch/RestierBatchHandler.cs +++ b/src/Microsoft.Restier.Publishers.OData/Batch/RestierBatchHandler.cs @@ -12,7 +12,6 @@ using System.Web.OData.Extensions; using Microsoft.Extensions.DependencyInjection; using Microsoft.OData; -using Microsoft.Restier.Core; namespace Microsoft.Restier.Publishers.OData.Batch { @@ -25,18 +24,11 @@ public class RestierBatchHandler : DefaultODataBatchHandler /// Initializes a new instance of the class. /// /// The HTTP server instance. - /// Gets or sets the callback to create API. - public RestierBatchHandler(HttpServer httpServer, Func apiFactory = null) + public RestierBatchHandler(HttpServer httpServer) : base(httpServer) { - this.ApiFactory = apiFactory; } - /// - /// Gets or sets the callback to create API. - /// - public Func ApiFactory { get; set; } - /// /// Asynchronously parses the batch requests. /// @@ -47,11 +39,6 @@ public override async Task> ParseBatchRequestsAsync HttpRequestMessage request, CancellationToken cancellationToken) { - if (this.ApiFactory == null) - { - throw new InvalidOperationException(Resources.BatchHandlerRequiresApiContextFactory); - } - Ensure.NotNull(request, "request"); IServiceProvider requestContainer = request.CreateRequestContainer(ODataRouteName); @@ -99,7 +86,7 @@ ODataMessageReader reader protected virtual RestierBatchChangeSetRequestItem CreateRestierBatchChangeSetRequestItem( IList changeSetRequests) { - return new RestierBatchChangeSetRequestItem(changeSetRequests, this.ApiFactory); + return new RestierBatchChangeSetRequestItem(changeSetRequests); } } } diff --git a/src/Microsoft.Restier.Publishers.OData/Batch/RestierChangeSetProperty.cs b/src/Microsoft.Restier.Publishers.OData/Batch/RestierChangeSetProperty.cs index 91f3f3b5..59a9cbc6 100644 --- a/src/Microsoft.Restier.Publishers.OData/Batch/RestierChangeSetProperty.cs +++ b/src/Microsoft.Restier.Publishers.OData/Batch/RestierChangeSetProperty.cs @@ -2,6 +2,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. using System.Linq; +using System.Net.Http; using System.Threading; using System.Threading.Tasks; using Microsoft.Restier.Core.Submit; @@ -37,12 +38,13 @@ public RestierChangeSetProperty(RestierBatchChangeSetRequestItem changeSetReques /// /// The callback to execute when the changeset is completed. /// + /// The http request message. /// The task object that represents this callback execution. - public Task OnChangeSetCompleted() + public Task OnChangeSetCompleted(HttpRequestMessage request) { if (Interlocked.Decrement(ref this.subRequestCount) == 0) { - this.changeSetRequestItem.SubmitChangeSet(this.ChangeSet) + this.changeSetRequestItem.SubmitChangeSet(request, this.ChangeSet) .ContinueWith(t => { if (t.Exception != null) diff --git a/src/Microsoft.Restier.Publishers.OData/Formatter/Serialization/RestierResourceSetSerializer.cs b/src/Microsoft.Restier.Publishers.OData/Formatter/Serialization/RestierResourceSetSerializer.cs index 389207c7..ac0f4527 100644 --- a/src/Microsoft.Restier.Publishers.OData/Formatter/Serialization/RestierResourceSetSerializer.cs +++ b/src/Microsoft.Restier.Publishers.OData/Formatter/Serialization/RestierResourceSetSerializer.cs @@ -56,17 +56,17 @@ private bool TryWriteAggregationResult( Type type, ODataMessageWriter messageWriter, ODataSerializerContext writeContext, - IEdmTypeReference feedType) + IEdmTypeReference resourceSetType) { if (typeof(IEnumerable).IsAssignableFrom(type)) { - IEdmTypeReference elementType = feedType.AsCollection().ElementType(); + IEdmTypeReference elementType = resourceSetType.AsCollection().ElementType(); if (elementType.IsEntity()) { var entitySet = writeContext.NavigationSource as IEdmEntitySetBase; var entityType = elementType.AsEntity(); var writer = messageWriter.CreateODataResourceSetWriter(entitySet, entityType.EntityDefinition()); - WriteObjectInline(graph, feedType, writer, writeContext); + WriteObjectInline(graph, resourceSetType, writer, writeContext); return true; } } diff --git a/src/Microsoft.Restier.Publishers.OData/Microsoft.Restier.Publishers.OData.csproj b/src/Microsoft.Restier.Publishers.OData/Microsoft.Restier.Publishers.OData.csproj index 9aed1bfd..774d0ca4 100644 --- a/src/Microsoft.Restier.Publishers.OData/Microsoft.Restier.Publishers.OData.csproj +++ b/src/Microsoft.Restier.Publishers.OData/Microsoft.Restier.Publishers.OData.csproj @@ -22,15 +22,15 @@ True - ..\..\packages\Microsoft.OData.Core.7.0.0-beta\lib\portable-net45+win8+wpa81\Microsoft.OData.Core.dll + ..\..\packages\Microsoft.OData.Core.7.0.0\lib\portable-net45+win8+wpa81\Microsoft.OData.Core.dll True - ..\..\packages\Microsoft.OData.Edm.7.0.0-beta\lib\portable-net45+win8+wpa81\Microsoft.OData.Edm.dll + ..\..\packages\Microsoft.OData.Edm.7.0.0\lib\portable-net45+win8+wpa81\Microsoft.OData.Edm.dll True - ..\..\packages\Microsoft.Spatial.7.0.0-beta\lib\portable-net45+win8+wpa81\Microsoft.Spatial.dll + ..\..\packages\Microsoft.Spatial.7.0.0\lib\portable-net45+win8+wpa81\Microsoft.Spatial.dll True @@ -50,7 +50,7 @@ True - ..\..\packages\Microsoft.AspNet.OData.6.0.0-Nightly160819\lib\net45\System.Web.OData.dll + ..\..\packages\Microsoft.AspNet.OData.6.0.0-Nightly160825\lib\net45\System.Web.OData.dll True diff --git a/src/Microsoft.Restier.Publishers.OData/RestierController.cs b/src/Microsoft.Restier.Publishers.OData/RestierController.cs index dfea734d..1e450fe3 100644 --- a/src/Microsoft.Restier.Publishers.OData/RestierController.cs +++ b/src/Microsoft.Restier.Publishers.OData/RestierController.cs @@ -179,7 +179,7 @@ public async Task Post(EdmEntityObject edmEntityObject, Cance { changeSetProperty.ChangeSet.Entries.Add(postItem); - await changeSetProperty.OnChangeSetCompleted(); + await changeSetProperty.OnChangeSetCompleted(this.Request); } return this.CreateCreatedODataResult(postItem.Resource); @@ -258,7 +258,7 @@ public async Task Delete(CancellationToken cancellationToken) { changeSetProperty.ChangeSet.Entries.Add(deleteItem); - await changeSetProperty.OnChangeSetCompleted(); + await changeSetProperty.OnChangeSetCompleted(this.Request); } return this.StatusCode(HttpStatusCode.NoContent); @@ -426,7 +426,7 @@ private async Task Update( { changeSetProperty.ChangeSet.Entries.Add(updateItem); - await changeSetProperty.OnChangeSetCompleted(); + await changeSetProperty.OnChangeSetCompleted(this.Request); } return this.CreateUpdatedODataResult(updateItem.Resource); diff --git a/src/Microsoft.Restier.Publishers.OData/Routing/HttpConfigurationExtensions.cs b/src/Microsoft.Restier.Publishers.OData/Routing/HttpConfigurationExtensions.cs index 8017a127..e4a0206f 100644 --- a/src/Microsoft.Restier.Publishers.OData/Routing/HttpConfigurationExtensions.cs +++ b/src/Microsoft.Restier.Publishers.OData/Routing/HttpConfigurationExtensions.cs @@ -38,19 +38,15 @@ public static class HttpConfigurationExtensions /// The instance. /// The name of the route. /// The prefix of the route. - /// The callback to create API instances. /// The handler for batch requests. /// The task object containing the resulted instance. public static Task MapRestierRoute( this HttpConfiguration config, string routeName, string routePrefix, - Func apiFactory, RestierBatchHandler batchHandler = null) where TApi : ApiBase { - Ensure.NotNull(apiFactory, "apiFactory"); - // This will be added a service to callback stored in ApiConfiguration // Callback is called by ApiBase.AddApiServices method to add real services. ApiConfiguration.AddPublisherServices( @@ -60,55 +56,22 @@ public static Task MapRestierRoute( services.AddODataServices(); }); - using (var api = apiFactory()) - { - Func func = () => new RestierContainerBuilder(api.GetType()); - config.UseCustomContainerBuilder(func); + Func func = () => new RestierContainerBuilder(typeof(TApi)); + config.UseCustomContainerBuilder(func); - var conventions = CreateRestierRoutingConventions(config, routeName, apiFactory); - if (batchHandler != null && batchHandler.ApiFactory == null) - { - batchHandler.ApiFactory = apiFactory; - batchHandler.ODataRouteName = routeName; - } - - Action configureAction = builder => builder - .AddService>(ServiceLifetime.Singleton, sp => conventions) - .AddService(ServiceLifetime.Singleton, sp => batchHandler); - - var route = config.MapODataServiceRoute(routeName, routePrefix, configureAction); + var conventions = CreateRestierRoutingConventions(config, routeName); + if (batchHandler != null) + { + batchHandler.ODataRouteName = routeName; + } - // Set ApiConfiguration instance for further usage - if (config != null) - { - var mapping = (ConcurrentDictionary)config.Properties[RootContainerKey]; - IServiceProvider rootContainer; - mapping.TryGetValue(routeName, out rootContainer); - api.Configuration = rootContainer.GetService(); - } + Action configureAction = builder => builder + .AddService>(ServiceLifetime.Singleton, sp => conventions) + .AddService(ServiceLifetime.Singleton, sp => batchHandler); - return Task.FromResult(route); - } - } + var route = config.MapODataServiceRoute(routeName, routePrefix, configureAction); - /// - /// Maps the API routes to the RestierController. - /// - /// The user API. - /// The instance. - /// The name of the route. - /// The prefix of the route. - /// The handler for batch requests. - /// The task object containing the resulted instance. - public static Task MapRestierRoute( - this HttpConfiguration config, - string routeName, - string routePrefix, - RestierBatchHandler batchHandler = null) - where TApi : ApiBase, new() - { - return MapRestierRoute( - config, routeName, routePrefix, () => new TApi(), batchHandler); + return Task.FromResult(route); } /// @@ -157,10 +120,9 @@ public static void SetUseVerboseErrors(this HttpConfiguration configuration, boo /// /// The instance. /// The name of the route. - /// The API factory. /// The routing conventions created. private static IList CreateRestierRoutingConventions( - this HttpConfiguration config, string routeName, Func apiFactory) + this HttpConfiguration config, string routeName) { var conventions = ODataRoutingConventions.CreateDefaultWithAttributeRouting(routeName, config); var index = 0; @@ -173,7 +135,7 @@ private static IList CreateRestierRoutingConventions( } } - conventions.Insert(index + 1, new RestierRoutingConvention(apiFactory)); + conventions.Insert(index + 1, new RestierRoutingConvention()); return conventions; } } diff --git a/src/Microsoft.Restier.Publishers.OData/Routing/RestierRoutingConvention.cs b/src/Microsoft.Restier.Publishers.OData/Routing/RestierRoutingConvention.cs index f900ceb1..876343c9 100644 --- a/src/Microsoft.Restier.Publishers.OData/Routing/RestierRoutingConvention.cs +++ b/src/Microsoft.Restier.Publishers.OData/Routing/RestierRoutingConvention.cs @@ -30,17 +30,6 @@ internal class RestierRoutingConvention : IODataRoutingConvention private const string MethodNameOfDelete = "Delete"; private const string MethodNameOfPostAction = "PostAction"; - private readonly Func apiFactory; - - /// - /// Initializes a new instance of the class. - /// - /// The API factory method. - public RestierRoutingConvention(Func apiFactory) - { - this.apiFactory = apiFactory; - } - /// /// Selects OData controller based on parsed OData URI /// @@ -69,10 +58,8 @@ public string SelectController(ODataPath odataPath, HttpRequestMessage request) } // Create ApiBase instance - // TODO need to change the way to create ApiBase var provider = request.GetRequestContainer(); var apiBase = provider.GetService(); - apiBase.ServiceProvider = provider; request.SetApiInstance(apiBase); return RestierControllerName; } diff --git a/src/Microsoft.Restier.Publishers.OData/packages.config b/src/Microsoft.Restier.Publishers.OData/packages.config index 7c4125c9..5a170e23 100644 --- a/src/Microsoft.Restier.Publishers.OData/packages.config +++ b/src/Microsoft.Restier.Publishers.OData/packages.config @@ -1,13 +1,13 @@  - + - - - + + + diff --git a/test/Microsoft.Restier.Core.Tests/Api.Tests.cs b/test/Microsoft.Restier.Core.Tests/Api.Tests.cs index 79ba6d44..2624423f 100644 --- a/test/Microsoft.Restier.Core.Tests/Api.Tests.cs +++ b/test/Microsoft.Restier.Core.Tests/Api.Tests.cs @@ -80,7 +80,7 @@ public Task ExecuteSubmitAsync(SubmitContext context, Cancellation private class TestApi : ApiBase { - public new static IServiceCollection ConfigureApi(Type apiType, IServiceCollection services) + public static new IServiceCollection ConfigureApi(Type apiType, IServiceCollection services) { var modelBuilder = new TestModelBuilder(); var modelMapper = new TestModelMapper(); @@ -97,10 +97,17 @@ private class TestApi : ApiBase return services; } + + public TestApi(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } private class TestApiEmpty : ApiBase { + public TestApiEmpty(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } [Fact] @@ -109,7 +116,6 @@ public void ApiSourceOfEntityContainerElementIsCorrect() var container = new RestierContainerBuilder(typeof(TestApi)); var provider = container.BuildContainer(); var api = provider.GetService(); - api.ServiceProvider = provider; var arguments = new object[0]; @@ -132,9 +138,9 @@ public void ApiSourceOfEntityContainerElementIsCorrect() [Fact] public void SourceOfEntityContainerElementThrowsIfNotMapped() { - var api = new TestApiEmpty(); var container = new RestierContainerBuilder(typeof(TestApiEmpty)); - api.Configuration = new ApiConfiguration(container.BuildContainer()); + var provider = container.BuildContainer(); + var api = provider.GetService(); var context = api.Context; var arguments = new object[0]; @@ -147,7 +153,6 @@ public void SourceOfEntityContainerElementIsCorrect() var container = new RestierContainerBuilder(typeof(TestApi)); var provider = container.BuildContainer(); var api = provider.GetService(); - api.ServiceProvider = provider; var context = api.Context; var arguments = new object[0]; @@ -173,7 +178,6 @@ public void ApiSourceOfComposableFunctionIsCorrect() var container = new RestierContainerBuilder(typeof(TestApi)); var provider = container.BuildContainer(); var api = provider.GetService(); - api.ServiceProvider = provider; var arguments = new object[0]; @@ -201,7 +205,6 @@ public void SourceOfComposableFunctionThrowsIfNotMapped() var container = new RestierContainerBuilder(typeof(TestApiEmpty)); var provider = container.BuildContainer(); var api = provider.GetService(); - api.ServiceProvider = provider; var context = api.Context; var arguments = new object[0]; @@ -214,7 +217,6 @@ public void SourceOfComposableFunctionIsCorrect() var container = new RestierContainerBuilder(typeof(TestApi)); var provider = container.BuildContainer(); var api = provider.GetService(); - api.ServiceProvider = provider; var context = api.Context; var arguments = new object[0]; @@ -243,7 +245,6 @@ public void GenericApiSourceOfEntityContainerElementIsCorrect() var container = new RestierContainerBuilder(typeof(TestApi)); var provider = container.BuildContainer(); var api = provider.GetService(); - api.ServiceProvider = provider; var arguments = new object[0]; @@ -269,7 +270,6 @@ public void GenericSourceOfEntityContainerElementThrowsIfWrongType() var container = new RestierContainerBuilder(typeof(TestApi)); var provider = container.BuildContainer(); var api = provider.GetService(); - api.ServiceProvider = provider; var context = api.Context; var arguments = new object[0]; @@ -282,7 +282,6 @@ public void GenericSourceOfEntityContainerElementIsCorrect() var container = new RestierContainerBuilder(typeof(TestApi)); var provider = container.BuildContainer(); var api = provider.GetService(); - api.ServiceProvider = provider; var context = api.Context; var arguments = new object[0]; @@ -309,7 +308,6 @@ public void GenericApiSourceOfComposableFunctionIsCorrect() var container = new RestierContainerBuilder(typeof(TestApi)); var provider = container.BuildContainer(); var api = provider.GetService(); - api.ServiceProvider = provider; var arguments = new object[0]; @@ -338,7 +336,6 @@ public void GenericSourceOfComposableFunctionThrowsIfWrongType() var container = new RestierContainerBuilder(typeof(TestApi)); var provider = container.BuildContainer(); var api = provider.GetService(); - api.ServiceProvider = provider; var context = api.Context; var arguments = new object[0]; @@ -352,7 +349,6 @@ public void GenericSourceOfComposableFunctionIsCorrect() var container = new RestierContainerBuilder(typeof(TestApi)); var provider = container.BuildContainer(); var api = provider.GetService(); - api.ServiceProvider = provider; var context = api.Context; var arguments = new object[0]; @@ -380,7 +376,6 @@ public void SourceQueryableCannotGenericEnumerate() var container = new RestierContainerBuilder(typeof(TestApi)); var provider = container.BuildContainer(); var api = provider.GetService(); - api.ServiceProvider = provider; var context = api.Context; var source = context.GetQueryableSource("Test"); @@ -393,7 +388,6 @@ public void SourceQueryableCannotEnumerate() var container = new RestierContainerBuilder(typeof(TestApi)); var provider = container.BuildContainer(); var api = provider.GetService(); - api.ServiceProvider = provider; var context = api.Context; var source = context.GetQueryableSource("Test"); @@ -403,7 +397,9 @@ public void SourceQueryableCannotEnumerate() [Fact] public void SourceQueryProviderCannotGenericExecute() { - var api = new TestApi(); + var container = new RestierContainerBuilder(typeof(TestApi)); + var provider = container.BuildContainer(); + var api = provider.GetService(); var context = api.Context; var source = context.GetQueryableSource("Test"); @@ -413,9 +409,9 @@ public void SourceQueryProviderCannotGenericExecute() [Fact] public void SourceQueryProviderCannotExecute() { - var api = new TestApi(); var container = new RestierContainerBuilder(typeof(TestApi)); - api.Configuration = new ApiConfiguration(container.BuildContainer()); + var provider = container.BuildContainer(); + var api = provider.GetService(); var context = api.Context; var source = context.GetQueryableSource("Test"); @@ -428,7 +424,6 @@ public async Task ApiQueryAsyncWithQueryReturnsResults() var container = new RestierContainerBuilder(typeof(TestApi)); var provider = container.BuildContainer(); var api = provider.GetService(); - api.ServiceProvider = provider; var request = new QueryRequest(api.GetQueryableSource("Test")); var result = await api.Context.QueryAsync(request); @@ -443,7 +438,6 @@ public async Task ApiQueryAsyncCorrectlyForwardsCall() var container = new RestierContainerBuilder(typeof(TestApi)); var provider = container.BuildContainer(); var api = provider.GetService(); - api.ServiceProvider = provider; var queryRequest = new QueryRequest( api.GetQueryableSource("Test")); @@ -455,7 +449,9 @@ public async Task ApiQueryAsyncCorrectlyForwardsCall() [Fact] public async Task ApiSubmitAsyncCorrectlyForwardsCall() { - var api = new TestApi(); + var container = new RestierContainerBuilder(typeof(TestApi)); + var provider = container.BuildContainer(); + var api = provider.GetService(); var submitResult = await api.SubmitAsync(); Assert.NotNull(submitResult.CompletedChangeSet); diff --git a/test/Microsoft.Restier.Core.Tests/ApiBase.Tests.cs b/test/Microsoft.Restier.Core.Tests/ApiBase.Tests.cs index 7d08fa96..5025baca 100644 --- a/test/Microsoft.Restier.Core.Tests/ApiBase.Tests.cs +++ b/test/Microsoft.Restier.Core.Tests/ApiBase.Tests.cs @@ -17,6 +17,10 @@ private class TestApi : ApiBase .MakeScoped() .AddService(); } + + public TestApi(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } interface IService @@ -42,10 +46,10 @@ public Service(ApiBase api, ApiContext context) [Fact] public void DefaultApiBaseCanBeCreatedAndDisposed() { - using (var api = new TestApi()) - { - api.Dispose(); - } + var container = new RestierContainerBuilder(typeof(TestApi)); + var provider = container.BuildContainer(); + var api = provider.GetService(); + api.Dispose(); } [Fact] @@ -54,9 +58,7 @@ public void ApiAndApiContextCanBeInjectedByDI() var container = new RestierContainerBuilder(typeof(TestApi)); var provider = container.BuildContainer(); var api = provider.GetService(); - api.ServiceProvider = provider; - // TODO, this will create a new scope and a new provider.... var context = api.Context; var svc = context.GetApiService(); diff --git a/test/Microsoft.Restier.Core.Tests/ApiConfiguration.Tests.cs b/test/Microsoft.Restier.Core.Tests/ApiConfiguration.Tests.cs index 95e6a612..cf4372e8 100644 --- a/test/Microsoft.Restier.Core.Tests/ApiConfiguration.Tests.cs +++ b/test/Microsoft.Restier.Core.Tests/ApiConfiguration.Tests.cs @@ -6,6 +6,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.OData.Edm; using Microsoft.Restier.Core.Model; using Xunit; @@ -20,12 +21,10 @@ public void CachedConfigurationIsCachedCorrectly() var container = new RestierContainerBuilder(typeof(TestApiA)); var provider = container.BuildContainer(); var api = provider.GetService(); - api.ServiceProvider = provider; var configuration = api.Context.Configuration; - ApiBase anotherApi = new TestApiA(); - anotherApi.ServiceProvider = provider; + ApiBase anotherApi = provider.GetService(); var cached = anotherApi.Context.Configuration; Assert.Same(configuration, cached); } @@ -36,15 +35,13 @@ public void ConfigurationRegistersApiServicesCorrectly() var container = new RestierContainerBuilder(typeof(TestApiA)); var provider = container.BuildContainer(); var api = provider.GetService(); - api.ServiceProvider = provider; Assert.Null(api.Context.GetApiService()); Assert.Null(api.Context.GetApiService()); container = new RestierContainerBuilder(typeof(TestApiB)); var provider2 = container.BuildContainer(); - var apiB = provider.GetService(); - apiB.ServiceProvider = provider2; + var apiB = provider2.GetService(); Assert.Same(TestApiB.serviceA, apiB.Context.GetApiService()); @@ -67,7 +64,6 @@ public void ServiceChainTest() var container = new RestierContainerBuilder(typeof(TestApiC)); var provider = container.BuildContainer(); var api = provider.GetService(); - api.ServiceProvider = provider; var handler = api.Context.GetApiService(); Assert.Equal("q2Pre_q1Pre_q1Post_q2Post_", handler.GetStr()); @@ -75,6 +71,9 @@ public void ServiceChainTest() private class TestApiA : ApiBase { + public TestApiA(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } private class TestApiB : ApiBase @@ -114,8 +113,18 @@ public static ServiceB serviceB services.AddService(); services.AddSingleton(new ServiceB()); + + services.AddScoped(apiType, apiType) + .AddScoped(typeof(ApiBase), apiType) + .AddScoped(); + + services.TryAddSingleton(); return services; } + + public TestApiB(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } private class TestApiC : ApiBase { @@ -130,8 +139,18 @@ private class TestApiC : ApiBase return q2; }); + services.AddScoped(apiType, apiType) + .AddScoped(typeof(ApiBase), apiType) + .AddScoped(); + + services.TryAddSingleton(); + return services; } + + public TestApiC(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } private class TestModelBuilder : IModelBuilder diff --git a/test/Microsoft.Restier.Core.Tests/ApiContext.Tests.cs b/test/Microsoft.Restier.Core.Tests/ApiContext.Tests.cs index ad6a0861..060398b0 100644 --- a/test/Microsoft.Restier.Core.Tests/ApiContext.Tests.cs +++ b/test/Microsoft.Restier.Core.Tests/ApiContext.Tests.cs @@ -11,6 +11,9 @@ public class ApiContextTests { private class TestApi : ApiBase { + public TestApi(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } [Fact] @@ -19,7 +22,6 @@ public void NewApiContextIsConfiguredCorrectly() var container = new RestierContainerBuilder(typeof(TestApi)); var provider = container.BuildContainer(); var api = provider.GetService(); - api.ServiceProvider = provider; var context = api.Context; Assert.NotNull(context.Configuration); diff --git a/test/Microsoft.Restier.Core.Tests/InvocationContext.Tests.cs b/test/Microsoft.Restier.Core.Tests/InvocationContext.Tests.cs index d363efb6..fb760933 100644 --- a/test/Microsoft.Restier.Core.Tests/InvocationContext.Tests.cs +++ b/test/Microsoft.Restier.Core.Tests/InvocationContext.Tests.cs @@ -3,6 +3,7 @@ using System; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; using Xunit; namespace Microsoft.Restier.Core.Tests @@ -25,12 +26,22 @@ public static ApiServiceA ApiService } } - public new static IServiceCollection ConfigureApi(Type apiType, IServiceCollection services) + public static new IServiceCollection ConfigureApi(Type apiType, IServiceCollection services) { + services.AddScoped(apiType, apiType) + .AddScoped(typeof(ApiBase), apiType) + .AddScoped(); + + services.TryAddSingleton(); + services.AddService((sp, next) => ApiService); return services; } + + public TestApi(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } [Fact] @@ -39,7 +50,6 @@ public void NewInvocationContextIsConfiguredCorrectly() var container = new RestierContainerBuilder(typeof(TestApi)); var provider = container.BuildContainer(); var api = provider.GetService(); - api.ServiceProvider = provider; var apiContext = api.Context; var context = new InvocationContext(apiContext); Assert.Same(apiContext, context.ApiContext); @@ -51,7 +61,6 @@ public void InvocationContextGetsApiServicesCorrectly() var container = new RestierContainerBuilder(typeof(TestApi)); var provider = container.BuildContainer(); var api = provider.GetService(); - api.ServiceProvider = provider; var apiContext = api.Context; var context = new InvocationContext(apiContext); Assert.Same(TestApi.ApiService, context.GetApiService()); diff --git a/test/Microsoft.Restier.Core.Tests/Microsoft.Restier.Core.Tests.csproj b/test/Microsoft.Restier.Core.Tests/Microsoft.Restier.Core.Tests.csproj index 2f69805a..5ce687a4 100644 --- a/test/Microsoft.Restier.Core.Tests/Microsoft.Restier.Core.Tests.csproj +++ b/test/Microsoft.Restier.Core.Tests/Microsoft.Restier.Core.Tests.csproj @@ -49,7 +49,7 @@ ..\..\packages\Microsoft.OData.Core.7.0.0-beta\lib\portable-net45+win8+wpa81\Microsoft.OData.Core.dll - ..\..\packages\Microsoft.OData.Edm.7.0.0-beta\lib\portable-net45+win8+wpa81\Microsoft.OData.Edm.dll + ..\..\packages\Microsoft.OData.Edm.7.0.0\lib\portable-net45+win8+wpa81\Microsoft.OData.Edm.dll True diff --git a/test/Microsoft.Restier.Core.Tests/Model/DefaultModelHandler.Tests.cs b/test/Microsoft.Restier.Core.Tests/Model/DefaultModelHandler.Tests.cs index 35bf0c39..ef9e4861 100644 --- a/test/Microsoft.Restier.Core.Tests/Model/DefaultModelHandler.Tests.cs +++ b/test/Microsoft.Restier.Core.Tests/Model/DefaultModelHandler.Tests.cs @@ -6,6 +6,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.OData.Edm; using Microsoft.Restier.Core.Model; using Xunit; @@ -27,8 +28,19 @@ private class TestApiA : ApiBase { InnerHandler = next, }); + + services.AddScoped(apiType, apiType) + .AddScoped(typeof(ApiBase), apiType) + .AddScoped(); + + services.TryAddSingleton(); + return services; } + + public TestApiA(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } private class TestApiB : ApiBase @@ -37,8 +49,18 @@ private class TestApiB : ApiBase { var service = new TestSingleCallModelBuilder(); services.AddService((sp, next) => service); + + services.AddScoped(apiType, apiType) + .AddScoped(typeof(ApiBase), apiType) + .AddScoped(); + + services.TryAddSingleton(); return services; } + + public TestApiB(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } private class TestApiC : ApiBase @@ -47,8 +69,19 @@ private class TestApiC : ApiBase { var service = new TestRetryModelBuilder(); services.AddService((sp, next) => service); + + services.AddScoped(apiType, apiType) + .AddScoped(typeof(ApiBase), apiType) + .AddScoped(); + + services.TryAddSingleton(); + return services; } + + public TestApiC(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } private class TestModelProducer : IModelBuilder @@ -107,7 +140,6 @@ public async Task GetModelUsingDefaultModelHandler() var container = new RestierContainerBuilder(typeof(TestApiA)); var provider = container.BuildContainer(); var api = provider.GetService(); - api.ServiceProvider = provider; var context = api.Context; var model = await context.GetModelAsync(); @@ -140,12 +172,8 @@ public async Task GetModelAsync(ModelContext context, CancellationTok } } - private static Task[] PrepareThreads(int count, Type apiType, ManualResetEventSlim wait) + private static Task[] PrepareThreads(int count, IServiceProvider provider, ManualResetEventSlim wait) { - var api2 = (ApiBase)Activator.CreateInstance(apiType); - var container = new RestierContainerBuilder(apiType); - api2.Configuration = new ApiConfiguration(container.BuildContainer()); - var tasks = new Task[count]; var result = Parallel.For(0, count, (inx, state) => { @@ -155,8 +183,9 @@ private static Task[] PrepareThreads(int count, Type apiType, ManualR // To make threads better aligned. wait.Wait(); - var api = (ApiBase)Activator.CreateInstance(apiType); - + var scopedProvider = + provider.GetRequiredService().CreateScope().ServiceProvider; + var api = scopedProvider.GetService(); var context = api.Context; try { @@ -182,7 +211,9 @@ public async Task ModelBuilderShouldBeCalledOnlyOnceIfSucceeded() { for (int i = 0; i < 2; i++) { - var tasks = PrepareThreads(50, typeof(TestApiB), wait); + var container = new RestierContainerBuilder(typeof(TestApiB)); + var provider = container.BuildContainer(); + var tasks = PrepareThreads(50, provider, wait); wait.Set(); var models = await Task.WhenAll(tasks); @@ -212,7 +243,10 @@ public async Task GetModelAsyncRetriableAfterFailure() { using (var wait = new ManualResetEventSlim(false)) { - var tasks = PrepareThreads(6, typeof(TestApiC), wait); + var container = new RestierContainerBuilder(typeof(TestApiC)); + var provider = container.BuildContainer(); + + var tasks = PrepareThreads(6, provider, wait); wait.Set(); await Task.WhenAll(tasks).ContinueWith(t => @@ -221,7 +255,7 @@ await Task.WhenAll(tasks).ContinueWith(t => Assert.True(tasks.All(e => e.IsFaulted)); }); - tasks = PrepareThreads(150, typeof(TestApiC), wait); + tasks = PrepareThreads(150, provider, wait); var models = await Task.WhenAll(tasks); Assert.True(models.All(e => object.ReferenceEquals(e, models[42]))); diff --git a/test/Microsoft.Restier.Core.Tests/PropertyBag.Tests.cs b/test/Microsoft.Restier.Core.Tests/PropertyBag.Tests.cs index 3e995679..70dfe2a0 100644 --- a/test/Microsoft.Restier.Core.Tests/PropertyBag.Tests.cs +++ b/test/Microsoft.Restier.Core.Tests/PropertyBag.Tests.cs @@ -15,7 +15,6 @@ public void PropertyBagManipulatesPropertiesCorrectly() var container = new RestierContainerBuilder(typeof(TestApi)); var provider = container.BuildContainer(); var api = provider.GetService(); - api.ServiceProvider = provider; var context =api.Context; Assert.False(context.HasProperty("Test")); @@ -41,15 +40,9 @@ public void DifferentPropertyBagsDoNotConflict() var container = new RestierContainerBuilder(typeof(TestApi)); var provider = container.BuildContainer(); var api = provider.GetService(); - api.ServiceProvider = provider; var context = api.Context; - var configuration = context.Configuration; - - configuration.SetProperty("Test", 1); context.SetProperty("Test", 2); - - Assert.Equal(1, configuration.GetProperty("Test")); Assert.Equal(2, context.GetProperty("Test")); } @@ -58,22 +51,23 @@ public void PropertyBagsAreDisposedCorrectly() { var container = new RestierContainerBuilder(typeof(TestApi)); var provider = container.BuildContainer(); - var api = provider.GetService(); - api.ServiceProvider = provider; + var scope = provider.GetRequiredService().CreateScope(); + var scopedProvider = scope.ServiceProvider; + var api = scopedProvider.GetService(); var context = api.Context; - var configuration = context.Configuration; - Assert.NotNull(configuration.GetApiService()); + Assert.NotNull(context.GetApiService()); Assert.Equal(1, MyPropertyBag.InstanceCount); - Assert.NotNull(context.GetApiService()); + var scopedProvider2 = provider.GetRequiredService().CreateScope().ServiceProvider; + var api2 = scopedProvider2.GetService(); + var context2 = api2.Context; + + Assert.NotNull(context2.GetApiService()); Assert.Equal(2, MyPropertyBag.InstanceCount); - // This will dispose all the scoped and transient instances registered - // in the ApiContext scope. - api.Dispose(); + scope.Dispose(); - // The one in ApiConfiguration will NOT be disposed until the service ends. Assert.Equal(1, MyPropertyBag.InstanceCount); } @@ -103,6 +97,10 @@ private class TestApi : ApiBase { return ApiBase.ConfigureApi(apiType, services).AddScoped(); } + + public TestApi(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } } } diff --git a/test/Microsoft.Restier.Core.Tests/ServiceConfiguration.Tests.cs b/test/Microsoft.Restier.Core.Tests/ServiceConfiguration.Tests.cs index be91333c..cb07e400 100644 --- a/test/Microsoft.Restier.Core.Tests/ServiceConfiguration.Tests.cs +++ b/test/Microsoft.Restier.Core.Tests/ServiceConfiguration.Tests.cs @@ -3,6 +3,7 @@ using System; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; using Xunit; namespace Microsoft.Restier.Core.Tests @@ -36,8 +37,17 @@ private class TestApiA : ApiBase }) .AddService(); + services.AddScoped(apiType, apiType) + .AddScoped(typeof(ApiBase), apiType) + .AddScoped(); + + services.TryAddSingleton(); return services; } + + public TestApiA(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } private class TestApiB : ApiBase @@ -52,8 +62,17 @@ private class TestApiB : ApiBase .AddService() .MakeTransient(); + services.AddScoped(apiType, apiType) + .AddScoped(typeof(ApiBase), apiType) + .AddScoped(); + + services.TryAddSingleton(); return services; } + + public TestApiB(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } private class TestApiC : ApiBase @@ -62,8 +81,18 @@ private class TestApiC : ApiBase { services.MakeScoped() .AddService((sp, next) => new SomeService()); + + services.AddScoped(apiType, apiType) + .AddScoped(typeof(ApiBase), apiType) + .AddScoped(); + + services.TryAddSingleton(); return services; } + + public TestApiC(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } private class TestApiD : ApiBase @@ -77,8 +106,18 @@ private class TestApiD : ApiBase }) .AddService() .MakeTransient(); + + services.AddScoped(apiType, apiType) + .AddScoped(typeof(ApiBase), apiType) + .AddScoped(); + + services.TryAddSingleton(); return services; } + + public TestApiD(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } private class TestApiE : ApiBase @@ -94,8 +133,17 @@ private class TestApiE : ApiBase .AddService() .AddSingleton("Text"); + services.AddScoped(apiType, apiType) + .AddScoped(typeof(ApiBase), apiType) + .AddScoped(); + + services.TryAddSingleton(); return services; } + + public TestApiE(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } private class TestApiF : ApiBase @@ -109,8 +157,18 @@ private class TestApiF : ApiBase .MakeTransient() .AddService(); + services.AddScoped(apiType, apiType) + .AddScoped(typeof(ApiBase), apiType) + .AddScoped(); + + services.TryAddSingleton(); + return services; } + + public TestApiF(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } private class TestApiG : ApiBase @@ -130,8 +188,18 @@ private class TestApiG : ApiBase .AddService((sp, next) => { return "0"; }) .MakeTransient(); + + services.AddScoped(apiType, apiType) + .AddScoped(typeof(ApiBase), apiType) + .AddScoped(); + + services.TryAddSingleton(); return services; } + + public TestApiG(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } private class TestApiH : ApiBase @@ -147,8 +215,17 @@ private class TestApiH : ApiBase .AddService((sp, next) => { return "0"; }) .MakeTransient(); + services.AddScoped(apiType, apiType) + .AddScoped(typeof(ApiBase), apiType) + .AddScoped(); + + services.TryAddSingleton(); return services; } + + public TestApiH(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } private class TestApiI : ApiBase @@ -166,8 +243,17 @@ private class TestApiI : ApiBase }) .AddService(); + services.AddScoped(apiType, apiType) + .AddScoped(typeof(ApiBase), apiType) + .AddScoped(); + + services.TryAddSingleton(); return services; } + + public TestApiI(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } @@ -299,7 +385,6 @@ public void ContributorsAreCalledCorrectly() var container = new RestierContainerBuilder(typeof(TestApiA)); var provider = container.BuildContainer(); var api = provider.GetService(); - api.ServiceProvider = provider; var value = api.Context.GetApiService().Call(); Assert.Equal("03210", value); } @@ -310,7 +395,6 @@ public void NextInjectedViaProperty() var container = new RestierContainerBuilder(typeof(TestApiB)); var provider = container.BuildContainer(); var api = provider.GetService(); - api.ServiceProvider = provider; var value = api.Context.GetApiService().Call(); Assert.Equal("01", value); @@ -325,19 +409,20 @@ public void ContextApiScopeWorksCorrectly() var container = new RestierContainerBuilder(typeof(TestApiC)); var provider = container.BuildContainer(); var api = provider.GetService(); - api.ServiceProvider = provider; var service1 = api.Context.GetApiService(); - - var api2 = new TestApiC(); + container = new RestierContainerBuilder(typeof(TestApiC)); - api2.Configuration = new ApiConfiguration(container.BuildContainer()); + provider = container.BuildContainer(); + var api2 = provider.GetService(); var service2 = api2.Context.GetApiService(); Assert.NotEqual(service1, service2); - var api3 = new TestApiC(); + container = new RestierContainerBuilder(typeof(TestApiC)); + provider = container.BuildContainer(); + var api3 = provider.GetService(); var service3 = api3.Context.GetApiService(); Assert.NotEqual(service3, service2); @@ -350,7 +435,6 @@ public void NothingInjectedStillWorks() var container = new RestierContainerBuilder(typeof(TestApiD)); var provider = container.BuildContainer(); var api = provider.GetService(); - api.ServiceProvider = provider; var value = api.Context.GetApiService().Call(); Assert.Equal("42", value); @@ -368,7 +452,6 @@ public void ServiceInjectedViaProperty() var container = new RestierContainerBuilder(typeof(TestApiE)); var provider = container.BuildContainer(); var api = provider.GetService(); - api.ServiceProvider = provider; var expected = "Text42"; var value = api.Context.GetApiService().Call(); @@ -391,7 +474,6 @@ public void DefaultValueInConstructorUsedIfNoService() var container = new RestierContainerBuilder(typeof(TestApiF)); var provider = container.BuildContainer(); var api = provider.GetService(); - api.ServiceProvider = provider; var value = api.Context.GetApiService().Call(); Assert.Equal("42", value); @@ -409,7 +491,6 @@ public void MultiInjectionViaConstructor() var container = new RestierContainerBuilder(typeof(TestApiG)); var provider = container.BuildContainer(); var api = provider.GetService(); - api.ServiceProvider = provider; var value = api.Context.GetApiService().Call(); Assert.Equal("0122", value); @@ -427,7 +508,6 @@ public void ThrowOnNoServiceFound() var container = new RestierContainerBuilder(typeof(TestApiH)); var provider = container.BuildContainer(); var api = provider.GetService(); - api.ServiceProvider = provider; Assert.Throws(() => { api.Context.GetApiService(); }); } @@ -438,7 +518,6 @@ public void NextInjectedWithInheritedField() var container = new RestierContainerBuilder(typeof(TestApiI)); var provider = container.BuildContainer(); var api = provider.GetService(); - api.ServiceProvider = provider; var value = api.Context.GetApiService().Call(); Assert.Equal("4200", value); diff --git a/test/Microsoft.Restier.Core.Tests/packages.config b/test/Microsoft.Restier.Core.Tests/packages.config index f7b385b9..2f607f5a 100644 --- a/test/Microsoft.Restier.Core.Tests/packages.config +++ b/test/Microsoft.Restier.Core.Tests/packages.config @@ -2,7 +2,7 @@ - + diff --git a/test/Microsoft.Restier.Providers.EntityFramework.Tests/ChangeSetPreparerTests.cs b/test/Microsoft.Restier.Providers.EntityFramework.Tests/ChangeSetPreparerTests.cs index 01534347..8cdd0bae 100644 --- a/test/Microsoft.Restier.Providers.EntityFramework.Tests/ChangeSetPreparerTests.cs +++ b/test/Microsoft.Restier.Providers.EntityFramework.Tests/ChangeSetPreparerTests.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Restier.Core; using Microsoft.Restier.Core.Submit; using Microsoft.Restier.Providers.EntityFramework.Tests.Models.Library; @@ -18,9 +19,9 @@ public class ChangeSetPreparerTests public async Task ComplexTypeUpdate() { // Arrange - var libraryApi = new LibraryApi(); var container = new RestierContainerBuilder(typeof(LibraryApi)); - libraryApi.Configuration = new ApiConfiguration(container.BuildContainer()); + var provider = container.BuildContainer(); + var libraryApi = provider.GetService(); var item = new DataModificationItem( "Readers", @@ -34,7 +35,7 @@ public async Task ComplexTypeUpdate() var sc = new SubmitContext(libraryApi.Context, changeSet); // Act - var changeSetPreparer = libraryApi.Context.Configuration.GetApiService(); + var changeSetPreparer = libraryApi.Context.GetApiService(); await changeSetPreparer.InitializeAsync(sc, CancellationToken.None); var person = item.Resource as Person; diff --git a/test/Microsoft.Restier.Providers.EntityFramework.Tests/Microsoft.Restier.Providers.EntityFramework.Tests.csproj b/test/Microsoft.Restier.Providers.EntityFramework.Tests/Microsoft.Restier.Providers.EntityFramework.Tests.csproj index 9a31f632..77b54efe 100644 --- a/test/Microsoft.Restier.Providers.EntityFramework.Tests/Microsoft.Restier.Providers.EntityFramework.Tests.csproj +++ b/test/Microsoft.Restier.Providers.EntityFramework.Tests/Microsoft.Restier.Providers.EntityFramework.Tests.csproj @@ -52,15 +52,15 @@ True - ..\..\packages\Microsoft.OData.Core.7.0.0-beta\lib\portable-net45+win8+wpa81\Microsoft.OData.Core.dll + ..\..\packages\Microsoft.OData.Core.7.0.0\lib\portable-net45+win8+wpa81\Microsoft.OData.Core.dll True - ..\..\packages\Microsoft.OData.Edm.7.0.0-beta\lib\portable-net45+win8+wpa81\Microsoft.OData.Edm.dll + ..\..\packages\Microsoft.OData.Edm.7.0.0\lib\portable-net45+win8+wpa81\Microsoft.OData.Edm.dll True - ..\..\packages\Microsoft.Spatial.7.0.0-beta\lib\portable-net45+win8+wpa81\Microsoft.Spatial.dll + ..\..\packages\Microsoft.Spatial.7.0.0\lib\portable-net45+win8+wpa81\Microsoft.Spatial.dll True @@ -79,7 +79,7 @@ True - ..\..\packages\Microsoft.AspNet.OData.6.0.0-Nightly160819\lib\net45\System.Web.OData.dll + ..\..\packages\Microsoft.AspNet.OData.6.0.0-Nightly160825\lib\net45\System.Web.OData.dll True diff --git a/test/Microsoft.Restier.Providers.EntityFramework.Tests/Models/Library/LibraryApi.cs b/test/Microsoft.Restier.Providers.EntityFramework.Tests/Models/Library/LibraryApi.cs index 72e70edb..8b6dfa9f 100644 --- a/test/Microsoft.Restier.Providers.EntityFramework.Tests/Models/Library/LibraryApi.cs +++ b/test/Microsoft.Restier.Providers.EntityFramework.Tests/Models/Library/LibraryApi.cs @@ -33,5 +33,9 @@ public Task GetModelAsync(ModelContext context, CancellationToken can return Task.FromResult(model); } } + + public LibraryApi(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } } diff --git a/test/Microsoft.Restier.Providers.EntityFramework.Tests/packages.config b/test/Microsoft.Restier.Providers.EntityFramework.Tests/packages.config index 3e4b21a4..b7ad8a88 100644 --- a/test/Microsoft.Restier.Providers.EntityFramework.Tests/packages.config +++ b/test/Microsoft.Restier.Providers.EntityFramework.Tests/packages.config @@ -1,14 +1,14 @@  - + - - - + + + diff --git a/test/Microsoft.Restier.Publishers.OData.Test/ExceptionHandlerTests.cs b/test/Microsoft.Restier.Publishers.OData.Test/ExceptionHandlerTests.cs index ded9f2cf..ba8bec91 100644 --- a/test/Microsoft.Restier.Publishers.OData.Test/ExceptionHandlerTests.cs +++ b/test/Microsoft.Restier.Publishers.OData.Test/ExceptionHandlerTests.cs @@ -38,6 +38,10 @@ private class ExcApi : StoreApi return StoreApi.ConfigureApi(apiType, services) .AddService((sp, next) => new FakeSourcer()); } + + public ExcApi(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } private class FakeSourcer : IQueryExpressionSourcer diff --git a/test/Microsoft.Restier.Publishers.OData.Test/FallbackTests.cs b/test/Microsoft.Restier.Publishers.OData.Test/FallbackTests.cs index a2920f82..124eea0e 100644 --- a/test/Microsoft.Restier.Publishers.OData.Test/FallbackTests.cs +++ b/test/Microsoft.Restier.Publishers.OData.Test/FallbackTests.cs @@ -110,6 +110,10 @@ public IQueryable PreservedOrders { get { return this.GetQueryableSource("Orders").Where(o => o.Id > 123); } } + + public FallbackApi(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } public class PeopleController : ODataController diff --git a/test/Microsoft.Restier.Publishers.OData.Test/Microsoft.Restier.Publishers.OData.Test.csproj b/test/Microsoft.Restier.Publishers.OData.Test/Microsoft.Restier.Publishers.OData.Test.csproj index 47eb9dd4..0f175aa9 100644 --- a/test/Microsoft.Restier.Publishers.OData.Test/Microsoft.Restier.Publishers.OData.Test.csproj +++ b/test/Microsoft.Restier.Publishers.OData.Test/Microsoft.Restier.Publishers.OData.Test.csproj @@ -52,15 +52,15 @@ True - ..\..\packages\Microsoft.OData.Core.7.0.0-beta\lib\portable-net45+win8+wpa81\Microsoft.OData.Core.dll + ..\..\packages\Microsoft.OData.Core.7.0.0\lib\portable-net45+win8+wpa81\Microsoft.OData.Core.dll True - ..\..\packages\Microsoft.OData.Edm.7.0.0-beta\lib\portable-net45+win8+wpa81\Microsoft.OData.Edm.dll + ..\..\packages\Microsoft.OData.Edm.7.0.0\lib\portable-net45+win8+wpa81\Microsoft.OData.Edm.dll True - ..\..\packages\Microsoft.Spatial.7.0.0-beta\lib\portable-net45+win8+wpa81\Microsoft.Spatial.dll + ..\..\packages\Microsoft.Spatial.7.0.0\lib\portable-net45+win8+wpa81\Microsoft.Spatial.dll True @@ -79,7 +79,7 @@ True - ..\..\packages\Microsoft.AspNet.OData.6.0.0-Nightly160819\lib\net45\System.Web.OData.dll + ..\..\packages\Microsoft.AspNet.OData.6.0.0-Nightly160825\lib\net45\System.Web.OData.dll True diff --git a/test/Microsoft.Restier.Publishers.OData.Test/Model/LibraryApi.cs b/test/Microsoft.Restier.Publishers.OData.Test/Model/LibraryApi.cs index 13773a73..2ebf0175 100644 --- a/test/Microsoft.Restier.Publishers.OData.Test/Model/LibraryApi.cs +++ b/test/Microsoft.Restier.Publishers.OData.Test/Model/LibraryApi.cs @@ -16,5 +16,9 @@ class LibraryApi : EntityFrameworkApi services.AddODataServices(); return services; } + + public LibraryApi(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } } diff --git a/test/Microsoft.Restier.Publishers.OData.Test/Model/RestierModelBuilderTests.cs b/test/Microsoft.Restier.Publishers.OData.Test/Model/RestierModelBuilderTests.cs index c7aaabfc..34afa351 100644 --- a/test/Microsoft.Restier.Publishers.OData.Test/Model/RestierModelBuilderTests.cs +++ b/test/Microsoft.Restier.Publishers.OData.Test/Model/RestierModelBuilderTests.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; +using Microsoft.Extensions.DependencyInjection; using Microsoft.OData.Edm; using Microsoft.OData.Edm.Validation; using Microsoft.Restier.Core; @@ -15,9 +16,10 @@ public class RestierModelBuilderTests [Fact] public void ComplexTypeShoudWork() { - var api = new LibraryApi(); var container = new RestierContainerBuilder(typeof(LibraryApi)); - api.Configuration = new ApiConfiguration(container.BuildContainer()); + var provider = container.BuildContainer(); + var api = provider.GetService(); + var model = api.Context.GetModelAsync().Result; IEnumerable errors; @@ -33,9 +35,9 @@ public void ComplexTypeShoudWork() [Fact] public void PrimitiveTypesShouldWork() { - var api = new LibraryApi(); var container = new RestierContainerBuilder(typeof(LibraryApi)); - api.Configuration = new ApiConfiguration(container.BuildContainer()); + var provider = container.BuildContainer(); + var api = provider.GetService(); var model = api.Context.GetModelAsync().Result; IEnumerable errors; diff --git a/test/Microsoft.Restier.Publishers.OData.Test/Model/RestierModelExtender.Tests.cs b/test/Microsoft.Restier.Publishers.OData.Test/Model/RestierModelExtender.Tests.cs index a44460c3..5211a707 100644 --- a/test/Microsoft.Restier.Publishers.OData.Test/Model/RestierModelExtender.Tests.cs +++ b/test/Microsoft.Restier.Publishers.OData.Test/Model/RestierModelExtender.Tests.cs @@ -1,9 +1,11 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Net.Http; using System.Threading; using System.Threading.Tasks; using System.Web.Http; +using System.Web.OData.Extensions; using Microsoft.Extensions.DependencyInjection; using Microsoft.OData.Edm; using Microsoft.Restier.Core; @@ -124,17 +126,20 @@ public async Task ApiModelBuilderShouldNotAddAmbiguousNavigationPropertyBindings // In this case, two entity sets Employees and People have entity type Person. // Bindings for collection navigation property Customer.Friends should NOT be added. // Bindings for singleton navigation property Customer.BestFriend should NOT be added. - var model = await this.GetModelAsync(); + var model = await GetModelAsync(); Assert.Empty(model.EntityContainer.FindEntitySet("Customers").NavigationPropertyBindings); Assert.Empty(model.EntityContainer.FindSingleton("Me").NavigationPropertyBindings); } - private async Task GetModelAsync() where T : BaseApi, new() + private async Task GetModelAsync() where T : BaseApi { - var api = (BaseApi)Activator.CreateInstance(); HttpConfiguration config = new HttpConfiguration(); await config.MapRestierRoute( "test", "api/test",null); + + var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/api/test"); + request.SetConfiguration(config); + var api = request.CreateRequestContainer("test").GetService(); return await api.Context.GetModelAsync(); } } @@ -178,10 +183,17 @@ public ApiConfiguration ApiConfiguration { get { return base.Configuration; } } + + public BaseApi(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } public class EmptyApi : BaseApi { + public EmptyApi(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } public class Person @@ -197,17 +209,25 @@ public class ApiA : BaseApi public Person Me { get; set; } public IQueryable Invisible { get; set; } - public new static IServiceCollection ConfigureApi(Type apiType, IServiceCollection services) + public static new IServiceCollection ConfigureApi(Type apiType, IServiceCollection services) { services.AddService((sp, next) => new TestModelBuilder()); return BaseApi.ConfigureApi(apiType, services); } + + public ApiA(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } public class ApiB : ApiA { [Resource] public IQueryable Customers { get; set; } + + public ApiB(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } public class Customer @@ -227,10 +247,17 @@ public class ApiC : ApiB public new IQueryable Customers { get; set; } [Resource(IsSingleton = true)] public new Customer Me { get; set; } + + public ApiC(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } public class ApiD : ApiC { + public ApiD(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } public class Order @@ -250,6 +277,10 @@ public class ApiE : BaseApi services.AddService((sp, next) => new TestModelBuilder()); return BaseApi.ConfigureApi(apiType, services); } + + public ApiE(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } public class ApiF : BaseApi @@ -261,12 +292,20 @@ public class ApiF : BaseApi services.AddService((sp, next) => new TestModelBuilder()); return BaseApi.ConfigureApi(apiType, services); } + + public ApiF(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } public class ApiG : ApiC { [Resource] public IQueryable Employees { get; set; } + + public ApiG(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } public class ApiH : BaseApi @@ -283,5 +322,9 @@ public class ApiH : BaseApi services.AddService((sp, next) => new TestModelBuilder()); return BaseApi.ConfigureApi(apiType, services); } + + public ApiH(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } } \ No newline at end of file diff --git a/test/Microsoft.Restier.Publishers.OData.Test/StoreApi.cs b/test/Microsoft.Restier.Publishers.OData.Test/StoreApi.cs index e3903241..9dbdaeeb 100644 --- a/test/Microsoft.Restier.Publishers.OData.Test/StoreApi.cs +++ b/test/Microsoft.Restier.Publishers.OData.Test/StoreApi.cs @@ -36,7 +36,7 @@ static StoreModel() internal class StoreApi : ApiBase { - public new static IServiceCollection ConfigureApi(Type apiType, IServiceCollection services) + public static new IServiceCollection ConfigureApi(Type apiType, IServiceCollection services) { services = ApiBase.ConfigureApi(apiType, services); services.AddService((sp, next) => new TestModelProducer(StoreModel.Model)); @@ -46,6 +46,10 @@ internal class StoreApi : ApiBase services.AddService((sp, next) => new TestSubmitExecutor()); return services; } + + public StoreApi(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } class Product diff --git a/test/Microsoft.Restier.Publishers.OData.Test/packages.config b/test/Microsoft.Restier.Publishers.OData.Test/packages.config index 3e4b21a4..b7ad8a88 100644 --- a/test/Microsoft.Restier.Publishers.OData.Test/packages.config +++ b/test/Microsoft.Restier.Publishers.OData.Test/packages.config @@ -1,14 +1,14 @@  - + - - - + + + diff --git a/test/Microsoft.Restier.TestCommon/PublicApi.bsl b/test/Microsoft.Restier.TestCommon/PublicApi.bsl index c3af0c26..5b294c9b 100644 --- a/test/Microsoft.Restier.TestCommon/PublicApi.bsl +++ b/test/Microsoft.Restier.TestCommon/PublicApi.bsl @@ -1,16 +1,16 @@ public abstract class Microsoft.Restier.Core.ApiBase : IDisposable { - protected ApiBase () + protected ApiBase (System.IServiceProvider serviceProvider) - Microsoft.Restier.Core.ApiConfiguration Configuration { public get; public set; } + Microsoft.Restier.Core.ApiConfiguration Configuration { public get; } Microsoft.Restier.Core.ApiContext Context { public get; } bool IsDisposed { [CompilerGeneratedAttribute(),]public get; } + System.IServiceProvider ServiceProvider { public get; } [ CLSCompliantAttribute(), ] public static Microsoft.Extensions.DependencyInjection.IServiceCollection ConfigureApi (System.Type apiType, Microsoft.Extensions.DependencyInjection.IServiceCollection services) - protected virtual Microsoft.Restier.Core.ApiContext CreateApiContext (Microsoft.Restier.Core.ApiConfiguration configuration) public virtual void Dispose () } @@ -54,41 +54,6 @@ public sealed class Microsoft.Restier.Core.ApiBaseExtensions { public static System.Threading.Tasks.Task`1[[Microsoft.Restier.Core.Submit.SubmitResult]] SubmitAsync (Microsoft.Restier.Core.ApiBase api, params Microsoft.Restier.Core.Submit.ChangeSet changeSet, params System.Threading.CancellationToken cancellationToken) } -[ -ExtensionAttribute(), -] -public sealed class Microsoft.Restier.Core.ApiConfigurationExtensions { - [ - ExtensionAttribute(), - ] - public static void ClearProperty (Microsoft.Restier.Core.ApiConfiguration configuration, string name) - - [ - ExtensionAttribute(), - ] - public static T GetApiService (Microsoft.Restier.Core.ApiConfiguration configuration) - - [ - ExtensionAttribute(), - ] - public static object GetProperty (Microsoft.Restier.Core.ApiConfiguration configuration, string name) - - [ - ExtensionAttribute(), - ] - public static T GetProperty (Microsoft.Restier.Core.ApiConfiguration configuration, string name) - - [ - ExtensionAttribute(), - ] - public static bool HasProperty (Microsoft.Restier.Core.ApiConfiguration configuration, string name) - - [ - ExtensionAttribute(), - ] - public static void SetProperty (Microsoft.Restier.Core.ApiConfiguration configuration, string name, object value) -} - [ ExtensionAttribute(), ] @@ -235,7 +200,7 @@ public sealed class Microsoft.Restier.Core.ServiceCollectionExtensions { } public class Microsoft.Restier.Core.ApiConfiguration { - public ApiConfiguration (System.IServiceProvider serviceProvider) + public ApiConfiguration () [ CLSCompliantAttribute(), @@ -249,7 +214,7 @@ public class Microsoft.Restier.Core.ApiConfiguration { } public class Microsoft.Restier.Core.ApiContext { - public ApiContext (Microsoft.Restier.Core.ApiConfiguration configuration) + public ApiContext (System.IServiceProvider provider, Microsoft.Restier.Core.ApiConfiguration configuration) Microsoft.Restier.Core.ApiConfiguration Configuration { [CompilerGeneratedAttribute(),]public get; } } @@ -561,7 +526,7 @@ public class Microsoft.Restier.Providers.EntityFramework.ChangeSetInitializer : } public class Microsoft.Restier.Providers.EntityFramework.EntityFrameworkApi`1 : Microsoft.Restier.Core.ApiBase, IDisposable { - public EntityFrameworkApi`1 () + public EntityFrameworkApi`1 (System.IServiceProvider serviceProvider) T DbContext { protected get; } @@ -586,11 +551,6 @@ public sealed class Microsoft.Restier.Publishers.OData.HttpConfigurationExtensio ] public static System.Threading.Tasks.Task`1[[System.Web.OData.Routing.ODataRoute]] MapRestierRoute (System.Web.Http.HttpConfiguration config, string routeName, string routePrefix, params Microsoft.Restier.Publishers.OData.Batch.RestierBatchHandler batchHandler) - [ - ExtensionAttribute(), - ] - public static System.Threading.Tasks.Task`1[[System.Web.OData.Routing.ODataRoute]] MapRestierRoute (System.Web.Http.HttpConfiguration config, string routeName, string routePrefix, System.Func`1[[Microsoft.Restier.Core.ApiBase]] apiFactory, params Microsoft.Restier.Publishers.OData.Batch.RestierBatchHandler batchHandler) - [ ExtensionAttribute(), ] @@ -654,7 +614,7 @@ public class Microsoft.Restier.Publishers.OData.RestierPayloadValueConverter : M } public class Microsoft.Restier.Publishers.OData.Batch.RestierBatchChangeSetRequestItem : System.Web.OData.Batch.ChangeSetRequestItem, IDisposable { - public RestierBatchChangeSetRequestItem (System.Collections.Generic.IEnumerable`1[[System.Net.Http.HttpRequestMessage]] requests, System.Func`1[[Microsoft.Restier.Core.ApiBase]] apiFactory) + public RestierBatchChangeSetRequestItem (System.Collections.Generic.IEnumerable`1[[System.Net.Http.HttpRequestMessage]] requests) [ AsyncStateMachineAttribute(), @@ -663,9 +623,7 @@ public class Microsoft.Restier.Publishers.OData.Batch.RestierBatchChangeSetReque } public class Microsoft.Restier.Publishers.OData.Batch.RestierBatchHandler : System.Web.OData.Batch.DefaultODataBatchHandler, IDisposable { - public RestierBatchHandler (System.Web.Http.HttpServer httpServer, params System.Func`1[[Microsoft.Restier.Core.ApiBase]] apiFactory) - - System.Func`1[[Microsoft.Restier.Core.ApiBase]] ApiFactory { [CompilerGeneratedAttribute(),]public get; [CompilerGeneratedAttribute(),]public set; } + public RestierBatchHandler (System.Web.Http.HttpServer httpServer) protected virtual Microsoft.Restier.Publishers.OData.Batch.RestierBatchChangeSetRequestItem CreateRestierBatchChangeSetRequestItem (System.Collections.Generic.IList`1[[System.Net.Http.HttpRequestMessage]] changeSetRequests) [ diff --git a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind.Tests/Microsoft.OData.Service.Sample.Northwind.Tests.csproj b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind.Tests/Microsoft.OData.Service.Sample.Northwind.Tests.csproj index 17b25189..4dd5d372 100644 --- a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind.Tests/Microsoft.OData.Service.Sample.Northwind.Tests.csproj +++ b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind.Tests/Microsoft.OData.Service.Sample.Northwind.Tests.csproj @@ -54,15 +54,15 @@ True - ..\..\..\packages\Microsoft.OData.Core.7.0.0-beta\lib\portable-net45+win8+wpa81\Microsoft.OData.Core.dll + ..\..\..\packages\Microsoft.OData.Core.7.0.0\lib\portable-net45+win8+wpa81\Microsoft.OData.Core.dll True - ..\..\..\packages\Microsoft.OData.Edm.7.0.0-beta\lib\portable-net45+win8+wpa81\Microsoft.OData.Edm.dll + ..\..\..\packages\Microsoft.OData.Edm.7.0.0\lib\portable-net45+win8+wpa81\Microsoft.OData.Edm.dll True - ..\..\..\packages\Microsoft.Spatial.7.0.0-beta\lib\portable-net45+win8+wpa81\Microsoft.Spatial.dll + ..\..\..\packages\Microsoft.Spatial.7.0.0\lib\portable-net45+win8+wpa81\Microsoft.Spatial.dll True @@ -85,7 +85,7 @@ True - ..\..\..\packages\Microsoft.AspNet.OData.6.0.0-Nightly160819\lib\net45\System.Web.OData.dll + ..\..\..\packages\Microsoft.AspNet.OData.6.0.0-Nightly160825\lib\net45\System.Web.OData.dll True diff --git a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind.Tests/QueryTests.cs b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind.Tests/QueryTests.cs index a940dfe9..6415fb8e 100644 --- a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind.Tests/QueryTests.cs +++ b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind.Tests/QueryTests.cs @@ -2,8 +2,11 @@ // Licensed under the MIT License. See License.txt in the project root for license information. using System.Linq; +using System.Net.Http; using System.Threading.Tasks; using System.Web.Http; +using System.Web.OData.Extensions; +using Microsoft.Extensions.DependencyInjection; using Microsoft.OData.Service.Sample.Northwind.Models; using Microsoft.Restier.Core; using Microsoft.Restier.Core.Query; @@ -13,13 +16,6 @@ namespace Microsoft.OData.Service.Sample.Northwind.Tests { public class QueryTests : TestBase { - private NorthwindApi api = new NorthwindApi(); - - private IQueryable OrdersQuery - { - get { return this.api.GetQueryableSource("Orders"); } - } - [Fact] public async Task TestTakeIncludeTotalCount() { @@ -27,9 +23,11 @@ public async Task TestTakeIncludeTotalCount() { using (HttpServer server = new HttpServer(config)) { - WebApiConfig.RegisterNorthwind(config, server); - QueryResult result = await this.api.QueryAsync( - new QueryRequest(this.OrdersQuery.OrderBy(o => o.OrderDate).Take(10))); + WebApiConfig.RegisterNorthwind(config, server); var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/api/test"); + request.SetConfiguration(config); + var api = request.CreateRequestContainer("NorthwindApi").GetService(); + QueryResult result = await api.QueryAsync( + new QueryRequest(api.GetQueryableSource("Orders").OrderBy(o => o.OrderDate).Take(10))); var orderResults = result.Results.OfType(); Assert.Equal(10, orderResults.Count()); @@ -45,8 +43,11 @@ public async Task TestSkipIncludeTotalCount() using (HttpServer server = new HttpServer(config)) { WebApiConfig.RegisterNorthwind(config, server); - QueryResult result = await this.api.QueryAsync( - new QueryRequest(this.OrdersQuery.OrderBy(o => o.OrderDate).Skip(10))); + var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/api/test"); + request.SetConfiguration(config); + var api = request.CreateRequestContainer("NorthwindApi").GetService(); + QueryResult result = await api.QueryAsync( + new QueryRequest(api.GetQueryableSource("Orders").OrderBy(o => o.OrderDate).Skip(10))); var orderResults = result.Results.OfType(); Assert.Equal(820, orderResults.Count()); @@ -62,8 +63,11 @@ public async Task TestSkipTakeIncludeTotalCount() using (HttpServer server = new HttpServer(config)) { WebApiConfig.RegisterNorthwind(config, server); - QueryResult result = await this.api.QueryAsync( - new QueryRequest(this.OrdersQuery.OrderBy(o => o.OrderDate).Skip(10).Take(25))); + var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/api/test"); + request.SetConfiguration(config); + var api = request.CreateRequestContainer("NorthwindApi").GetService(); + QueryResult result = await api.QueryAsync( + new QueryRequest(api.GetQueryableSource("Orders").OrderBy(o => o.OrderDate).Skip(10).Take(25))); var orderResults = result.Results.OfType(); Assert.Equal(25, orderResults.Count()); @@ -83,8 +87,11 @@ public async Task TestTakeNotStrippedIncludeTotalCount() using (HttpServer server = new HttpServer(config)) { WebApiConfig.RegisterNorthwind(config, server); - QueryResult result = await this.api.QueryAsync( - new QueryRequest(this.OrdersQuery.Take(10).OrderBy(o => o.OrderDate))); + var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/api/test"); + request.SetConfiguration(config); + var api = request.CreateRequestContainer("NorthwindApi").GetService(); + QueryResult result = await api.QueryAsync( + new QueryRequest(api.GetQueryableSource("Orders").Take(10).OrderBy(o => o.OrderDate))); var orderResults = result.Results.OfType(); Assert.Equal(10, orderResults.Count()); diff --git a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind.Tests/SaveTests.cs b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind.Tests/SaveTests.cs index 3fea4bf5..0c5521e1 100644 --- a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind.Tests/SaveTests.cs +++ b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind.Tests/SaveTests.cs @@ -45,6 +45,10 @@ protected async Task OnInsertingCustomers(Customer customer) await Task.Delay(10); customer.CompanyName += "OnInserting"; } + + public TestEntityFilterReturnsTaskApi(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } /// @@ -53,9 +57,10 @@ protected async Task OnInsertingCustomers(Customer customer) [Fact] public async Task TestEntityFilterReturnsTask() { - TestEntityFilterReturnsTaskApi api = new TestEntityFilterReturnsTaskApi(); var container = new RestierContainerBuilder(typeof(TestEntityFilterReturnsTaskApi)); - api.Configuration = new ApiConfiguration(container.BuildContainer()); + var provider = container.BuildContainer(); + var api = provider.GetService(); + DataModificationItem createCustomer = new DataModificationItem( "Customers", typeof(Customer), diff --git a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind.Tests/packages.config b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind.Tests/packages.config index 4774e229..12cf5010 100644 --- a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind.Tests/packages.config +++ b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind.Tests/packages.config @@ -1,15 +1,15 @@  - + - - - + + + diff --git a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind/Controllers/NorthwindController.cs b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind/Controllers/NorthwindController.cs index d3195fbf..155c33a9 100644 --- a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind/Controllers/NorthwindController.cs +++ b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind/Controllers/NorthwindController.cs @@ -12,33 +12,22 @@ using System.Net; using System.Web.Http; using System.Web.OData; +using System.Web.OData.Extensions; using System.Web.OData.Routing; +using Microsoft.Extensions.DependencyInjection; using Microsoft.OData.Service.Sample.Northwind.Models; +using Microsoft.Restier.Core; namespace Microsoft.OData.Service.Sample.Northwind.Controllers { public class NorthwindController : ODataController { - private NorthwindApi api; - - private NorthwindApi Api - { - get - { - if (api == null) - { - api = new NorthwindApi(); - } - - return api; - } - } - private NorthwindContext DbContext { get { - return Api.Context; + var api =(NorthwindApi)this.Request.GetRequestContainer().GetService(); + return api.Context; } } @@ -116,22 +105,5 @@ public IHttpActionResult ResetDataSource() DbContext.ResetDataSource(); return StatusCode(HttpStatusCode.NoContent); } - - /// - /// Disposes the API and the controller. - /// - /// Indicates whether disposing is happening. - protected override void Dispose(bool disposing) - { - if (disposing) - { - if (this.api != null) - { - this.api.Dispose(); - } - } - - base.Dispose(disposing); - } } } diff --git a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind/Microsoft.OData.Service.Sample.Northwind.csproj b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind/Microsoft.OData.Service.Sample.Northwind.csproj index 758ee629..96c202b7 100644 --- a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind/Microsoft.OData.Service.Sample.Northwind.csproj +++ b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind/Microsoft.OData.Service.Sample.Northwind.csproj @@ -58,15 +58,15 @@ True - ..\..\..\packages\Microsoft.OData.Core.7.0.0-beta\lib\portable-net45+win8+wpa81\Microsoft.OData.Core.dll + ..\..\..\packages\Microsoft.OData.Core.7.0.0\lib\portable-net45+win8+wpa81\Microsoft.OData.Core.dll True - ..\..\..\packages\Microsoft.OData.Edm.7.0.0-beta\lib\portable-net45+win8+wpa81\Microsoft.OData.Edm.dll + ..\..\..\packages\Microsoft.OData.Edm.7.0.0\lib\portable-net45+win8+wpa81\Microsoft.OData.Edm.dll True - ..\..\..\packages\Microsoft.Spatial.7.0.0-beta\lib\portable-net45+win8+wpa81\Microsoft.Spatial.dll + ..\..\..\packages\Microsoft.Spatial.7.0.0\lib\portable-net45+win8+wpa81\Microsoft.Spatial.dll True @@ -101,7 +101,7 @@ - ..\..\..\packages\Microsoft.AspNet.OData.6.0.0-Nightly160819\lib\net45\System.Web.OData.dll + ..\..\..\packages\Microsoft.AspNet.OData.6.0.0-Nightly160825\lib\net45\System.Web.OData.dll True diff --git a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind/Models/NorthwindApi.cs b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind/Models/NorthwindApi.cs index 31d93cd5..720219d6 100644 --- a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind/Models/NorthwindApi.cs +++ b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind/Models/NorthwindApi.cs @@ -104,5 +104,9 @@ public async Task GetModelAsync(ModelContext context, CancellationTok return model; } } + + public NorthwindApi(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } } \ No newline at end of file diff --git a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind/packages.config b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind/packages.config index 2183d93a..c9abcf9e 100644 --- a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind/packages.config +++ b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind/packages.config @@ -1,16 +1,16 @@  - + - - - + + + diff --git a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Trippin/Api/TrippinApi.cs b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Trippin/Api/TrippinApi.cs index 556f4a40..a44f1841 100644 --- a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Trippin/Api/TrippinApi.cs +++ b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Trippin/Api/TrippinApi.cs @@ -648,5 +648,9 @@ public async Task GetModelAsync(ModelContext context, CancellationTok return model; } } + + public TrippinApi(IServiceProvider serviceProvider) : base(serviceProvider) + { + } } } \ No newline at end of file diff --git a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Trippin/Controllers/PeopleController.cs b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Trippin/Controllers/PeopleController.cs index 7c4d914a..894d0521 100644 --- a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Trippin/Controllers/PeopleController.cs +++ b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Trippin/Controllers/PeopleController.cs @@ -9,34 +9,22 @@ using System.Web.OData; using System.Web.OData.Extensions; using System.Web.OData.Routing; +using Microsoft.Extensions.DependencyInjection; using Microsoft.OData.Edm; using Microsoft.OData.Service.Sample.Trippin.Api; using Microsoft.OData.Service.Sample.Trippin.Models; +using Microsoft.Restier.Core; namespace Microsoft.OData.Service.Sample.Trippin.Controllers { public class PeopleController : ODataController { - private TrippinApi api; - - private TrippinApi Api - { - get - { - if (api == null) - { - api = new TrippinApi(); - } - - return api; - } - } - private TrippinModel DbContext { get { - return Api.ModelContext; + var api = (TrippinApi)this.Request.GetRequestContainer().GetService(); + return api.ModelContext; } } diff --git a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Trippin/Controllers/TrippinController.cs b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Trippin/Controllers/TrippinController.cs index 4d9056bd..2214343e 100644 --- a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Trippin/Controllers/TrippinController.cs +++ b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Trippin/Controllers/TrippinController.cs @@ -8,33 +8,21 @@ using System.Web.OData; using System.Web.OData.Extensions; using System.Web.OData.Routing; +using Microsoft.Extensions.DependencyInjection; using Microsoft.OData.Service.Sample.Trippin.Api; using Microsoft.OData.Service.Sample.Trippin.Models; +using Microsoft.Restier.Core; namespace Microsoft.OData.Service.Sample.Trippin.Controllers { public class TrippinController : ODataController { - private TrippinApi api; - - private TrippinApi Api - { - get - { - if (api == null) - { - api = new TrippinApi(); - } - - return api; - } - } - private TrippinModel DbContext { get { - return Api.ModelContext; + var api = (TrippinApi)this.Request.GetRequestContainer().GetService(); + return api.ModelContext; } } @@ -98,23 +86,6 @@ public IHttpActionResult DeleteRefToAirLineFromFlight([FromODataUri] int key) return StatusCode(HttpStatusCode.NoContent); } - /// - /// Disposes the API and the controller. - /// - /// Indicates whether disposing is happening. - protected override void Dispose(bool disposing) - { - if (disposing) - { - if (this.api != null) - { - this.api.Dispose(); - } - } - - base.Dispose(disposing); - } - private string GetServiceRootUri() { var routeName = Request.ODataProperties().RouteName; diff --git a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Trippin/Microsoft.OData.Service.Sample.Trippin.csproj b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Trippin/Microsoft.OData.Service.Sample.Trippin.csproj index d55c2434..df8d09ab 100644 --- a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Trippin/Microsoft.OData.Service.Sample.Trippin.csproj +++ b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Trippin/Microsoft.OData.Service.Sample.Trippin.csproj @@ -123,15 +123,15 @@ True - ..\..\..\packages\Microsoft.OData.Core.7.0.0-beta\lib\portable-net45+win8+wpa81\Microsoft.OData.Core.dll + ..\..\..\packages\Microsoft.OData.Core.7.0.0\lib\portable-net45+win8+wpa81\Microsoft.OData.Core.dll True - ..\..\..\packages\Microsoft.OData.Edm.7.0.0-beta\lib\portable-net45+win8+wpa81\Microsoft.OData.Edm.dll + ..\..\..\packages\Microsoft.OData.Edm.7.0.0\lib\portable-net45+win8+wpa81\Microsoft.OData.Edm.dll True - ..\..\..\packages\Microsoft.Spatial.7.0.0-beta\lib\portable-net45+win8+wpa81\Microsoft.Spatial.dll + ..\..\..\packages\Microsoft.Spatial.7.0.0\lib\portable-net45+win8+wpa81\Microsoft.Spatial.dll True @@ -160,7 +160,7 @@ True - ..\..\..\packages\Microsoft.AspNet.OData.6.0.0-Nightly160819\lib\net45\System.Web.OData.dll + ..\..\..\packages\Microsoft.AspNet.OData.6.0.0-Nightly160825\lib\net45\System.Web.OData.dll True diff --git a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Trippin/packages.config b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Trippin/packages.config index 2183d93a..c9abcf9e 100644 --- a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Trippin/packages.config +++ b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Trippin/packages.config @@ -1,16 +1,16 @@  - + - - - + + + diff --git a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.TrippinInMemory/Api/TrippinApi.cs b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.TrippinInMemory/Api/TrippinApi.cs index 744ef5ea..322cd71b 100644 --- a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.TrippinInMemory/Api/TrippinApi.cs +++ b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.TrippinInMemory/Api/TrippinApi.cs @@ -34,6 +34,10 @@ private string Key get { return InMemoryProviderUtils.GetSessionId(); } } + public TrippinApi(IServiceProvider serviceProvider) : base(serviceProvider) + { + } + #region Entity Set [Resource] @@ -337,7 +341,7 @@ private static double CalculateDistance(GeographyPoint p1, GeographyPoint p2) #endregion - public new static IServiceCollection ConfigureApi(Type apiType, IServiceCollection services) + public static new IServiceCollection ConfigureApi(Type apiType, IServiceCollection services) { Func> defaultDataStoreManager = sp => new DefaultDataStoreManager() diff --git a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.TrippinInMemory/Controllers/TrippinController.cs b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.TrippinInMemory/Controllers/TrippinController.cs index d4cb4976..6b7433cd 100644 --- a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.TrippinInMemory/Controllers/TrippinController.cs +++ b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.TrippinInMemory/Controllers/TrippinController.cs @@ -4,8 +4,11 @@ using System.Linq; using System.Web.Http; using System.Web.OData; +using System.Web.OData.Extensions; using System.Web.OData.Routing; +using Microsoft.Extensions.DependencyInjection; using Microsoft.OData.Service.Sample.TrippinInMemory.Api; +using Microsoft.Restier.Core; namespace Microsoft.OData.Service.Sample.TrippinInMemory.Controllers { @@ -18,7 +21,7 @@ private TrippinApi Api { if (_api == null) { - _api = new TrippinApi(); + _api = (TrippinApi)this.Request.GetRequestContainer().GetService(); } return _api; diff --git a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.TrippinInMemory/Microsoft.OData.Service.Sample.TrippinInMemory.csproj b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.TrippinInMemory/Microsoft.OData.Service.Sample.TrippinInMemory.csproj index 3948488b..425ce830 100644 --- a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.TrippinInMemory/Microsoft.OData.Service.Sample.TrippinInMemory.csproj +++ b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.TrippinInMemory/Microsoft.OData.Service.Sample.TrippinInMemory.csproj @@ -52,15 +52,15 @@ True - ..\..\..\packages\Microsoft.OData.Core.7.0.0-beta\lib\portable-net45+win8+wpa81\Microsoft.OData.Core.dll + ..\..\..\packages\Microsoft.OData.Core.7.0.0\lib\portable-net45+win8+wpa81\Microsoft.OData.Core.dll True - ..\..\..\packages\Microsoft.OData.Edm.7.0.0-beta\lib\portable-net45+win8+wpa81\Microsoft.OData.Edm.dll + ..\..\..\packages\Microsoft.OData.Edm.7.0.0\lib\portable-net45+win8+wpa81\Microsoft.OData.Edm.dll True - ..\..\..\packages\Microsoft.Spatial.7.0.0-beta\lib\portable-net45+win8+wpa81\Microsoft.Spatial.dll + ..\..\..\packages\Microsoft.Spatial.7.0.0\lib\portable-net45+win8+wpa81\Microsoft.Spatial.dll True @@ -92,7 +92,7 @@ True - ..\..\..\packages\Microsoft.AspNet.OData.6.0.0-Nightly160819\lib\net45\System.Web.OData.dll + ..\..\..\packages\Microsoft.AspNet.OData.6.0.0-Nightly160825\lib\net45\System.Web.OData.dll True diff --git a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.TrippinInMemory/packages.config b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.TrippinInMemory/packages.config index b2a89a5d..c0d4e7dc 100644 --- a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.TrippinInMemory/packages.config +++ b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.TrippinInMemory/packages.config @@ -1,15 +1,15 @@  - + - - - + + + diff --git a/test/ODataEndToEnd/Microsoft.Restier.Providers.InMemory/Microsoft.Restier.Providers.InMemory.csproj b/test/ODataEndToEnd/Microsoft.Restier.Providers.InMemory/Microsoft.Restier.Providers.InMemory.csproj index 03ef1c18..437ecc8e 100644 --- a/test/ODataEndToEnd/Microsoft.Restier.Providers.InMemory/Microsoft.Restier.Providers.InMemory.csproj +++ b/test/ODataEndToEnd/Microsoft.Restier.Providers.InMemory/Microsoft.Restier.Providers.InMemory.csproj @@ -39,15 +39,15 @@ True - ..\..\..\packages\Microsoft.OData.Core.7.0.0-beta\lib\portable-net45+win8+wpa81\Microsoft.OData.Core.dll + ..\..\..\packages\Microsoft.OData.Core.7.0.0\lib\portable-net45+win8+wpa81\Microsoft.OData.Core.dll True - ..\..\..\packages\Microsoft.OData.Edm.7.0.0-beta\lib\portable-net45+win8+wpa81\Microsoft.OData.Edm.dll + ..\..\..\packages\Microsoft.OData.Edm.7.0.0\lib\portable-net45+win8+wpa81\Microsoft.OData.Edm.dll True - ..\..\..\packages\Microsoft.Spatial.7.0.0-beta\lib\portable-net45+win8+wpa81\Microsoft.Spatial.dll + ..\..\..\packages\Microsoft.Spatial.7.0.0\lib\portable-net45+win8+wpa81\Microsoft.Spatial.dll True @@ -66,7 +66,7 @@ True - ..\..\..\packages\Microsoft.AspNet.OData.6.0.0-Nightly160819\lib\net45\System.Web.OData.dll + ..\..\..\packages\Microsoft.AspNet.OData.6.0.0-Nightly160825\lib\net45\System.Web.OData.dll True diff --git a/test/ODataEndToEnd/Microsoft.Restier.Providers.InMemory/packages.config b/test/ODataEndToEnd/Microsoft.Restier.Providers.InMemory/packages.config index b5340e2e..383d37bd 100644 --- a/test/ODataEndToEnd/Microsoft.Restier.Providers.InMemory/packages.config +++ b/test/ODataEndToEnd/Microsoft.Restier.Providers.InMemory/packages.config @@ -1,13 +1,13 @@  - + - - - + + +