I have an asp.net mvc 3 web application that has plugin assemblies that implement system-dependent EF contexts and services.
For example, I have an assembly that looks like this in general:
System1Controller : IController // from System.Web.Mvc ISystem1Service { IList<System1Type> GetOperation(string something); } System1Service : ISystem1Service { private ISystem1Entities context; public System1Service(ISystem1Entities context) { this.context = context; } } ISystem1Entities { IDbSet<System1Type> Operations { get; set; } } System1Entities : DbContext, ISystem1Entities
Using Unity Bootstrapper and calling Bootstrapper.Initialize () works with the following BuildUnityContainer () implementation
private static IUnityContainer BuildUnityContainer() { var theContainer = new UnityContainer(); var connectionString = ConfigurationManager.ConnectionStrings["WebAppConnectionString"]; if (connectionString == null) { throw new ApplicationException("The ConnectionString is not defined."); }
I want to reorganize the bootloader so that I can load "unknown" in assembly-time assemblies, register the types that are contained in them, and allow the web application to access the controller, services, contexts as needed.
I looked at the Unity AutoRegistraion project, and it looks like I'm getting me in the implementation area that I want, but I donβt know how to implement the following idea:
BootStrapper.BuildUnityConfiguration Initialize Container RegisterMyAssemblies()
I want the RegisterMyAssemblies process to register a wildcard list of assemblies, and then start registering types in each individual assembly. Any suggestions?
source share