diff --git a/package.props b/package.props index 3173af6..cd4df8e 100644 --- a/package.props +++ b/package.props @@ -1,8 +1,8 @@ - 2.0.7 - This package is compatible with NET Core 1.1, 2.0+ + 2.0.8 + Bug fixes and minor performance optimizations diff --git a/src/ServiceProvider.cs b/src/ServiceProvider.cs index 58ec87d..b9de14f 100644 --- a/src/ServiceProvider.cs +++ b/src/ServiceProvider.cs @@ -53,7 +53,7 @@ public IServiceScope CreateScope() #endregion - #region ConfigureServices + #region Public Members public static IServiceProvider ConfigureServices(IServiceCollection services) { @@ -61,6 +61,11 @@ public static IServiceProvider ConfigureServices(IServiceCollection services) .AddServices(services)); } + public static explicit operator UnityContainer(ServiceProvider c) + { + return (UnityContainer)c._container; + } + #endregion diff --git a/src/ServiceProviderExtensions.cs b/src/ServiceProviderExtensions.cs index 407d93f..cdca61d 100644 --- a/src/ServiceProviderExtensions.cs +++ b/src/ServiceProviderExtensions.cs @@ -20,5 +20,31 @@ public static IServiceProvider BuildServiceProvider(this IServiceCollection serv return new ServiceProvider(new UnityContainer().AddExtension(new MdiExtension()) .AddServices(services)); } + + /// + /// Creates a containing services from the provided + /// optionaly enabling scope validation. + /// + /// The containing service descriptors. + /// Parent container + /// Service provider + public static IServiceProvider BuildServiceProvider(this IServiceCollection services, IUnityContainer container) + { + return new ServiceProvider(container.AddExtension(new MdiExtension()) + .AddServices(services)); + } + + /// + /// Creates a containing services from the provided + /// optionaly enabling scope validation. + /// + /// The containing service descriptors. + /// Parent container + /// Service provider + public static IServiceProvider BuildServiceProvider(this IUnityContainer container, IServiceCollection services) + { + return new ServiceProvider(container.AddExtension(new MdiExtension()) + .AddServices(services)); + } } }