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?
// 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();
I have read that there is an interface to implement to add dependencies to the umbraco controller but it only applies to plugins. I jneed these dependencies in my site generally, not just in plugins.
I'm really stuck. So any help or pointers would be really appreciated. Thanks
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?
==============Standard Autofac Container Registrations===========
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>();
==============Standard Autofac Container Registrations===========
==============Umbraco Global================
protected override Umbraco.Framework.DependencyManagement.AbstractContainerBuilder CreateContainerBuilder()
{
var builder = base.CreateContainerBuilder();
//Need Standard Autofac Container Registrations above added to builder here
return builder;
}
==============Umbraco Global================
I have read that there is an interface to implement to add dependencies to the umbraco controller but it only applies to plugins. I jneed these dependencies in my site generally, not just in plugins.
I'm really stuck. So any help or pointers would be really appreciated. Thanks
Dean
is working on a reply...