public static AssemblyRegistrationList RegisterAssemblies(this IServiceCollection services, AppDomain domain = null) { var all = (domain ?? AppDomain.CurrentDomain).GetAssemblies() .Select(x => new { Assembly = x, Core = x.GetCustomAttribute <RegisterAssemblyAttribute>() }) .Where(x => x.Core != null); var list = new AssemblyRegistrationList(services); foreach (var item in all) { list.Add(item.Assembly, item.Core?.RegisterParts ?? false, item.Core?.StartupType); } list.Add(Assembly.GetEntryAssembly(), true); return(list); }
public static IMvcBuilder RegisterApplicationParts(this IMvcBuilder mvcBuilder, AssemblyRegistrationList list, params Assembly[] other) { foreach (var o in other) { mvcBuilder.AddApplicationPart(o); } foreach (var a in list.List) { mvcBuilder.AddApplicationPart(a); } return(mvcBuilder); }