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 14, 2012 @ 02:54
    Dean
    0

    How to add these Autofac registrations to the umbraco 5 AbstractContainerBuilder?

    Hello,

    Could anyone please help me rewrite these Autofac.ContainerBuilder registrations to work with the Umbraco.Framework.DependecyManagement.AbstractContainerBuilder returned by the CreateContainerBuilder method in the Global.ascx file?

    ContainerBuilder autoFacContainerBuilder = new ContainerBuilder();

    autoFacContainerBuilder.RegisterGeneric(typeof(EFRepository<>)).As(typeof(IRepository<>));
    autoFacContainerBuilder.RegisterGeneric(typeof(EFReadOnlyRepository<>)).As(typeof(IReadOnlyRepository<>));

    autoFacContainerBuilder.RegisterType<ClientEFRepository>().As<IClientRepository>();
    autoFacContainerBuilder.RegisterType<CustomWebsiteTemplateEFRepository>().As<ICustomWebsiteTemplateRepository>();
    autoFacContainerBuilder.RegisterType<GenericWebsiteTemplateEFRepository>().As<IGenericWebsiteTemplateRepository>();
    autoFacContainerBuilder.RegisterType<GoogleFontEFRepository>().As<IGoogleFontRepository>();
    autoFacContainerBuilder.RegisterType<WebsiteEFRepository>().As<IWebsiteRepository>();

    // Unit of Work & ObjectContext - Autofac DI Registration
    autoFacContainerBuilder.RegisterType<EFUnitOfWork>().As<IUnitOfWork>();
    autoFacContainerBuilder.RegisterType<ObjectContextAdapter>().As<IObjectContext>();
    autoFacContainerBuilder.Register(c => new YourWebsiteEntities()).As<ObjectContext>().InstancePerLifetimeScope();

    // Services - Autofac DI Registration
    autoFacContainerBuilder.RegisterType<ClientService>().As<IClientService>();
    autoFacContainerBuilder.RegisterType<CustomWebsiteTemplateService>().As<ICustomWebsiteTemplateService>();
    autoFacContainerBuilder.RegisterType<GenericWebsiteTemplateService>().As<IGenericWebsiteTemplateService>();
    autoFacContainerBuilder.RegisterType<GoogleFontService>().As<IGoogleFontService>();
    autoFacContainerBuilder.RegisterType<WebsiteService>().As<IWebsiteService>();

    I'm really stuck. So any help or pointers would be really appreciated. Thanks

    Dean

Please Sign in or register to post replies

Write your reply to:

Draft