Skip to content

Simple Object Factory supports Dependency Injection pattern in .NET

License

Notifications You must be signed in to change notification settings

adriangodong/simple-object-factory

Repository files navigation

simple-object-factory

Simple Object Factory supports Dependency Injection pattern in .NET. SOF simplifies creation of types with chained dependencies. SOF is reflection-based constructor-injection library.

Build status NuGet

Usage:

// Class definitions:

public class Foo
{
}

public class Bar
{
    public Bar(Foo foo)
    {
    }
}

public class Baz
{
    public Baz(Bar bar)
    {
    }
}

// Instantiate ObjectFactory and register types

ObjectFactory objectFactory = new ObjectFactory();
objectFactory.RegisterType<Foo>();
objectFactory.RegisterType<Bar>();
objectFactory.RegisterType<Baz>();

// Automatically instantiate registered types

Foo foo = objectFactory.GetInstance<Foo>();
Bar bar = objectFactory.GetInstance<Bar>();
Baz baz = objectFactory.GetInstance<Baz>();

About

Simple Object Factory supports Dependency Injection pattern in .NET

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages