Skip to content

Instantly share code, notes, and snippets.

@StacyGay
Created July 12, 2014 21:15
Show Gist options
  • Save StacyGay/c8fe77fababe00ed74a7 to your computer and use it in GitHub Desktop.
Save StacyGay/c8fe77fababe00ed74a7 to your computer and use it in GitHub Desktop.
DI Child Container
public class SubContext
{
private readonly IUnityContainer _childContainer;
public SubContext(IUnityContainer container)
{
_childContainer = container.CreateChildContainer();
_childContainer.RegisterType<IBusinessLogicService, AltLogicService>();
}
public void Execute()
{
var doer = _childContainer.Resolve<Doer>();
Console.WriteLine(doer.DoIt(4));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment