Unity.Ioc.Framework 1.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Unity.Ioc.Framework --version 1.1.0
                    
NuGet\Install-Package Unity.Ioc.Framework -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Unity.Ioc.Framework" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Unity.Ioc.Framework" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Unity.Ioc.Framework" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Unity.Ioc.Framework --version 1.1.0
                    
#r "nuget: Unity.Ioc.Framework, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Unity.Ioc.Framework@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Unity.Ioc.Framework&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Unity.Ioc.Framework&version=1.1.0
                    
Install as a Cake Tool

Unity.Ioc.Framework

Unity.Ioc.Framework

a unity IoC framework extension for Microsoft.Practices.Unity

C# .NET Version NuGet Downloads

QuickStart

Interface & implementation

    [ServiceImplementation]
    public class TestClass : ITestInterface
    {
        public void TestMethod(string a)
        {
            Console.WriteLine("input:{0}", a);
        }
    }
           
   ITestInterface service = ServiceLocator.GetInstance<ITestInterface>();
   service.TestMethod("Hello world!");

AppConfig File Setting

add packing section and moduleAssemblies that assembly the of the interface implementation class

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="packing" type="Unity.Ioc.Framework.Configuration.PackingSection,Unity.Ioc.Framework"/>
  </configSections>

  <packing>
    <moduleAssemblies>
      <add name="Unity.Ioc.Framework.Test.Implementation"/>
    </moduleAssemblies>
  </packing>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
  </startup>
</configuration>

Advance

Create Singleton Instance (Lifetime.Singleton)

    [ServiceImplementation(ResolveLifetime =Lifetime.Singleton)]
    public class TestClass2 : ITestInterface
    {
        public void TestMethod(string a)
        {
            Console.WriteLine("input:{0}", a);
        }
    }

A new object is created each time an instance is obtained (default Lifetime.New)

    [ServiceImplementation(ResolveLifetime =Lifetime.New)]
    public class TestClass2 : ITestInterface
    {
        public void TestMethod(string a)
        {
            Console.WriteLine("input:{0}", a);
        }
    }

Return different objects for different thread contexts, and return the same object for the same thread (default Lifetime.PerThread)

    [ServiceImplementation(ResolveLifetime =Lifetime.PerThread)]
    public class TestClass2 : ITestInterface
    {
        public void TestMethod(string a)
        {
            Console.WriteLine("input:{0}", a);
        }
    }

a interface has muti implementation class

    [ServiceImplementation( Name ="class_a",ResolveLifetime =Lifetime.New)]
    public class TestClass2 : ITestInterface
    {
        public void TestMethod(string a)
        {
            Console.WriteLine("input:{0}", a);
        }
    }

    ITestInterface service = ServiceLocator.GetInstance<ITestInterface>("class_a");
    service.TestMethod("Hello world!");

Product Compatible and additional computed target framework versions.
.NET Framework net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 133 4/11/2026
1.1.0 92 4/11/2026
1.0.0 53,069 1/23/2017

Upgrade to .NET Framework 4.8