skynyrd
10/12/2016 - 6:47 AM

Autofac life time scope tricks

Autofac life time scope tricks

// C#, Performance, Autofac, Dependency Injection
// Default scope : Instance per dependency
// If you inject like this:

ctor(Func<IYourType> yourType){}

// And use it in your method as:
yourType = new YourType();

// Then you get new instance everytime your method is called.
// But if you register as .SingleInstance,
// Then it will return you the same object even you inject Func to your class.