Skip to content

NoSharp/SimpleIOC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple IoC

A simple IoC container for those projects where you don't want to have to add another dependency.

How to?

Checkout the example if you're confused.

Using the IoC Container.

    // Set an instance in the container.
    IocContainer.Instance.Set<Interface, ConcreteClass>( Constructor, Parameters );
    
    // Get the Interface you've set.
    IocContainer.Instance.Get<Interface>(); 

Using the constructor Injector Example:

public class Test2 : ITest2
{

    public Test2(ITest test, string test2, string test3)
    {
        Console.WriteLine($"Test2: {test2}");
        Console.WriteLine($"Test3: {test3}");
        test.Print();
    }
}

When using Set it will infer the constructor parameters, where possible, meaning that if you have an interface in the container it'll grab that rather than taking it form the arguments in Set.

Installation

Copy IocContainer.cs From the project IOCContainer and put it in your solution. That's it. One file.

About

A very simple IOC container with constructor injection.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages