Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Dean 55 posts 98 karma points
    Apr 12, 2012 @ 13:52
    Dean
    0

    Registering With Autofac Container in Global.asax equivelant to StructureMap?

    Hello All,

    I'm using umbraco 5.

    I have overriden the CreateContainerBuilder method in glabal asax and have called base.CreateContainerBuilder() to get access to a variable of it's return type, AbstractContainerBuilder.

    I've then used this variable to register my dependencies.

    public class Global : MvcApplication
    {
    protected override Umbraco.Framework.DependencyManagement.AbstractContainerBuilder CreateContainerBuilder()
    {
    var container = base.CreateContainerBuilder();

    container.For(typeof(EFRepository<>)).KnownAs(typeof(IRepository<>));
    return container;
    }

    I'm following a tutorial on IOC/DI and that uses StructureMap as it's container. There is a registration that i'd like to place inside the method above but I don't know how to write it for Autofac and in the context of that AbstractContainerBuilder.

    The structure map line looks like this: For<ObjectContext>().HybridHttpOrThreadLocalScoped().Use(() => new Entities());

     

    Can anyone please translate that line into something I can use in the umbraco scenario?

     

    Any assistance greatly appreciated

    Dean

     

     

     

Please Sign in or register to post replies

Write your reply to:

Draft