Skip to content

Instantly share code, notes, and snippets.

@JakeGinnivan
Created April 9, 2013 07:14
Show Gist options
  • Select an option

  • Save JakeGinnivan/5343635 to your computer and use it in GitHub Desktop.

Select an option

Save JakeGinnivan/5343635 to your computer and use it in GitHub Desktop.
public class Foo : IFoo
{
public Foo(string state, ISomeDepedency dep){}
}
public interface IFooFactory
{
IFoo Create(string state);
}
public class FooFactory : IFooFactory
{
ISOmeDep _dep;
public FooFactory(ISomeDependency dep){
_dep = dep;
}
public IFoo Create(string state)
{
return new Foo(state, _dep);
}
}
public void ContainerConfiguration(ContainerBuilder cb)
{
cb.RegisterType<FooFactory>().As<IFooFactory>().InstancePerHttpRequest();
cb.RegisterType<SomeDependency>().As<ISomeDependency>().InstancePerHttpRequest();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment