AP.Core.IocManager 2.0.0

A flexible IocC Container  supports .Net Framework and .Net Core 2.0
Fast and Support IServiceProvider integration

Install-Package AP.Core.IocManager -Version 2.0.0
dotnet add package AP.Core.IocManager --version 2.0.0
<PackageReference Include="AP.Core.IocManager" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AP.Core.IocManager --version 2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: AP.Core.IocManager, 2.0.0"
#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 AP.Core.IocManager as a Cake Addin
#addin nuget:?package=AP.Core.IocManager&version=2.0.0

// Install AP.Core.IocManager as a Cake Tool
#tool nuget:?package=AP.Core.IocManager&version=2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Update Ver2.0.0

Change method Registration IServiceCollectioncan

IoC.Container.RegisterFromServiceCollection(services) ⇒ IoC.Container.Populate(services);
    public IServiceProvider ConfigureServices(IServiceCollection services)
    {
        services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        //IoC.Container.RegisterFromServiceCollection(services)
        IoC.Container.Populate(services);
        return IoC.Container.AsServiceProvider();
    }

Add method IoC.Container.RegisterAssemblyTypes('endType')

    public interface IDemoService : IBaseService
    {
    }
    public interface IDemo2Service : IBaseService
    {
    }

    public class DemoService : IDemoService
    {
        public string Name { get; set; }


        public string Print(string name)
        {
            this.Name = name;
            return String.Concat("Hello", this.Name);
        }

    }
    public class Demo2Service : IDemo2Service
    {
        public string Name { get; set; }


        public string Print(string name)
        {
            this.Name = name;
            return String.Concat("Hello2", this.Name);
        }
    }

You can easily implement your own method to register all assembly types for a given assembly or set of assemblies. The code would be along the lines of:

    public void ConfigureServices(IServiceCollection services)
    {
        //Get all class for assembly name end with key "Service"
        var assembly = Assembly.GetExecutingAssembly();
        IoC.Container.RegisterAssemblyTypes("Service", assembly); // Default "ReuseType.Transient"
        //Or With LifeScope
        //IoC.Container.RegisterAssemblyTypes("Service", assembly, ReuseType.Singleton);
    }

Controller Inject Service

public class ValuesController : ControllerBase
{
    private readonly IDemoService _demoSrv;
    public ValuesController(IDemoService demoSrv)
    {
        this._demoSrv = demoSrv;
    }
}

Update Ver2.0.0

Change method Registration IServiceCollectioncan

IoC.Container.RegisterFromServiceCollection(services) ⇒ IoC.Container.Populate(services);
    public IServiceProvider ConfigureServices(IServiceCollection services)
    {
        services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        //IoC.Container.RegisterFromServiceCollection(services)
        IoC.Container.Populate(services);
        return IoC.Container.AsServiceProvider();
    }

Add method IoC.Container.RegisterAssemblyTypes('endType')

    public interface IDemoService : IBaseService
    {
    }
    public interface IDemo2Service : IBaseService
    {
    }

    public class DemoService : IDemoService
    {
        public string Name { get; set; }


        public string Print(string name)
        {
            this.Name = name;
            return String.Concat("Hello", this.Name);
        }

    }
    public class Demo2Service : IDemo2Service
    {
        public string Name { get; set; }


        public string Print(string name)
        {
            this.Name = name;
            return String.Concat("Hello2", this.Name);
        }
    }

You can easily implement your own method to register all assembly types for a given assembly or set of assemblies. The code would be along the lines of:

    public void ConfigureServices(IServiceCollection services)
    {
        //Get all class for assembly name end with key "Service"
        var assembly = Assembly.GetExecutingAssembly();
        IoC.Container.RegisterAssemblyTypes("Service", assembly); // Default "ReuseType.Transient"
        //Or With LifeScope
        //IoC.Container.RegisterAssemblyTypes("Service", assembly, ReuseType.Singleton);
    }

Controller Inject Service

public class ValuesController : ControllerBase
{
    private readonly IDemoService _demoSrv;
    public ValuesController(IDemoService demoSrv)
    {
        this._demoSrv = demoSrv;
    }
}

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
2.0.0 776 6/29/2018
1.5.0 667 6/28/2018
1.4.0 676 6/28/2018
1.3.0 634 6/26/2018
1.2.0 587 6/26/2018
1.1.0 611 6/25/2018