Is it dangerous or will it cause any strange and obscure bugs if I use Autofac's assembly scanning to automatically register everything (e.g. controllers, interfaces, etc.). The code is below:
public class DependencyInjectionConfig : IApplicationEventHandler
{
public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
var builder = new ContainerBuilder();
var plugins = new List
// Scan and auto-register EVERYTHING with an interface. This picks up MVC controllers in plugins too!
builder.RegisterAssemblyTypes(assemblies)
.Where(t => !t.GetCustomAttributes<ExcludeAutoRegistrationAttribute>().Any())
.AsImplementedInterfaces()
.AsSelf();
var container = builder.Build();
var resolver = new AutofacWebApiDependencyResolver(container);
GlobalConfiguration.Configuration.DependencyResolver = resolver;
DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
}
public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
}
public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
}
Autofac + Umbraco 7. Auto-register all assemblies dangerous?
Is it dangerous or will it cause any strange and obscure bugs if I use Autofac's assembly scanning to automatically register everything (e.g. controllers, interfaces, etc.). The code is below:
public class DependencyInjectionConfig : IApplicationEventHandler {
public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) { var builder = new ContainerBuilder(); var plugins = new List
}
is working on a reply...