MPDC.Container
1.0.5
See the version list below for details.
dotnet add package MPDC.Container --version 1.0.5
NuGet\Install-Package MPDC.Container -Version 1.0.5
<PackageReference Include="MPDC.Container" Version="1.0.5" />
paket add MPDC.Container --version 1.0.5
#r "nuget: MPDC.Container, 1.0.5"
// Install MPDC.Container as a Cake Addin #addin nuget:?package=MPDC.Container&version=1.0.5 // Install MPDC.Container as a Cake Tool #tool nuget:?package=MPDC.Container&version=1.0.5
For a sample interface IService and its implementation class SomeService:
public interface IService { int GetMillion(); }
public class SomeService : IService
{
public int GetMillion()
{
return 1000000;
}
}
We can register object instance by its abstraction: MPDCContainer.Instance.Register<IService, SomeService>(new SomeService());
If we don't want to create instance instantly, we can use overloaded method: MPDCContainer.Instance.Register<IService, SomeService>(() ⇒ new SomeService());
This will create instance of SomeService only when it is requested.
To request instance use simple Get method and pass the abstraction used to register the SomeService: MPDCContainer.Instance.Get<IService>();
var myNumber = MPDCContainer.Instance.Get<IService>().GetMillion(); //myNumber will be 1000000
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net is compatible. |
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
1.0.0 public release