Unity.Microsoft.DependencyInjection 1.0.1

Unity for Microsoft Dependency Injection framework.

There is a newer version of this package available.
See the version list below for details.
Install-Package Unity.Microsoft.DependencyInjection -Version 1.0.1
dotnet add package Unity.Microsoft.DependencyInjection --version 1.0.1
<PackageReference Include="Unity.Microsoft.DependencyInjection" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Unity.Microsoft.DependencyInjection --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Unity.Microsoft.DependencyInjection, 1.0.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Unity.Microsoft.DependencyInjection as a Cake Addin
#addin nuget:?package=Unity.Microsoft.DependencyInjection&version=1.0.1

// Install Unity.Microsoft.DependencyInjection as a Cake Tool
#tool nuget:?package=Unity.Microsoft.DependencyInjection&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Get Started

  • Reference the Unity.Microsoft.DependencyInjection package from NuGet.
Install-Package Unity.Microsoft.DependencyInjection

First way:

  • In the WebHostBuilder add ConfigureServices(services => services.AddUnity()) method
public static IWebHost BuildWebHost(string[] args) =>
    WebHost.CreateDefaultBuilder(args)
        .ConfigureServices(services => services.AddUnity())
        .UseStartup<Startup>()
        .Build();
  • Add method to your Startup class
public void ConfigureContainer(IUnityContainer container)
{
  container.RegisterType<IMyService, MyService>();
}

Second way:

  • In the ConfigureServices method of your Startup class...
    • Register services from the IServiceCollection.
    • Build your container.
    • Call ConfigureServices extension on IUnityContainer and return it.
public IServiceProvider ConfigureServices(IServiceCollection services)
{
  services.AddMvc();
  
  var container = new UnityContainer();
  
  container.RegisterType<IMyService, MyService>();
  
  return container.ConfigureServices(services);
}

Get Started

  • Reference the Unity.Microsoft.DependencyInjection package from NuGet.
Install-Package Unity.Microsoft.DependencyInjection

First way:

  • In the WebHostBuilder add ConfigureServices(services => services.AddUnity()) method
public static IWebHost BuildWebHost(string[] args) =>
    WebHost.CreateDefaultBuilder(args)
        .ConfigureServices(services => services.AddUnity())
        .UseStartup<Startup>()
        .Build();
  • Add method to your Startup class
public void ConfigureContainer(IUnityContainer container)
{
  container.RegisterType<IMyService, MyService>();
}

Second way:

  • In the ConfigureServices method of your Startup class...
    • Register services from the IServiceCollection.
    • Build your container.
    • Call ConfigureServices extension on IUnityContainer and return it.
public IServiceProvider ConfigureServices(IServiceCollection services)
{
  services.AddMvc();
  
  var container = new UnityContainer();
  
  container.RegisterType<IMyService, MyService>();
  
  return container.ConfigureServices(services);
}

Release Notes

This package is distributed as .NET Standard 1.0 package. It is compatible with Microsoft.Extensions.DependencyInjection.Abstractions specification.

NuGet packages (7)

Showing the top 5 NuGet packages that depend on Unity.Microsoft.DependencyInjection:

Package Downloads
UnityAddon.Core
Package Description
IFramework.DependencyInjection.Unity
Supports netcore standard2.0
PSFiddle.Common
Package Description
S-Innovations.ServiceFabric.RegistrationMiddleware.AspNetCore
Package Description
Acv2.SharedKernel.Infraestructure
Package Description

GitHub repositories (2)

Showing the top 2 popular GitHub repositories that depend on Unity.Microsoft.DependencyInjection:

Repository Stars
dotnet/runtime
.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
danielpalme/IocPerformance
Performance comparison of .NET IoC containers

Version History

Version Downloads Last updated
5.11.5 369,853 12/12/2019
5.11.4 6,634 12/8/2019
5.11.3 1,316 12/8/2019
5.11.2 508 12/8/2019
5.11.1 6,997 12/6/2019
5.11.0 1,045 12/6/2019
5.10.2 224,224 4/10/2019
5.10.1 37,213 3/23/2019
5.10.0 52,034 3/18/2019
5.9.2 3,337 3/2/2019
5.9.1 10,434 2/6/2019
5.9.0 7,228 1/23/2019
2.1.3 178,010 12/9/2018
2.1.2.1 9,813 12/4/2018
2.1.1 31,196 8/29/2018
2.1.0 2,220 8/25/2018
2.0.12 545 8/24/2018
2.0.11 491 8/22/2018
2.0.10 175,187 3/27/2018
2.0.9 2,811 3/4/2018
2.0.8 840 3/4/2018
2.0.7 585 3/1/2018
2.0.6 1,726 1/29/2018
2.0.5 644 1/23/2018
2.0.4 604 1/23/2018
2.0.3 558 1/23/2018
2.0.2 802 1/11/2018
2.0.1 625 1/10/2018
2.0.0 760 1/9/2018
1.0.1 4,530 1/5/2018
1.0.0 785 1/4/2018
Show less