ipjohnson / Grace

Grace is a feature rich dependency injection container library
MIT License
336 stars 33 forks source link

Make IInjectionScope resolvable by default #125

Closed mcdis closed 6 years ago

mcdis commented 6 years ago
var container = new DependencyInjectionContainer(_ => _.Behaviors.ConstructorSelection = ConstructorSelectionMethod.Dynamic);
var child = container.CreateChildScope();

child.Configure(_=>_.ExportAs<A,IA>());
child.Locate<IA>(); <--- Fail

where:

class A:IA
{
   public A(IInjectionScope _container)
   {
   }
}
ipjohnson commented 6 years ago

Hi @mcdis

while it's not the default behavior you can set _.Behaviors.AllowInjectionScopeLocation = true and it will behave the way you want. It might make sense to inherit from the configuration and set a couple of these values to be more "Unity".

mcdis commented 6 years ago

yeah! thanks