Skip to content

jmcd/YATC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Yet another tiny container.  A wee IoC container I wrote for fun and learning.

Use it like so:

public interface IService {}

public interface ICache<T> {}

public class MyService : IService
{
    public MyService(ICache<string> cache){}
}

public class Cache<T> : ICache<T>
{
    public Cache(IList<string> store){}
}

var container = new Container()
    .Register<IService, MyService>()                               // Register class for interface
    .Register<ICache<string>, Cache<string>>(Lifestyle.Singleton)  // Register specific type of open-generic, also make it singleton
    .Register<IList<string>>(() => new List<string>())             // Register implentation by factory method
    ;

var service = container.Resolve<IService>();
 

About

Yet another tiny (IoC) container

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published