public static LazyBlazorPluginBuilder UseLazyBlazorPlugins(this WebAssemblyHostBuilder builder) { // create own LightInject container so that it can be injected and manipulated later. used for late loading services var container = new ServiceContainer(); container.RegisterInstance(container); // use LightInject builder.ConfigureContainer(new LightInjectServiceProviderFactory(container)); var thisAssembly = Assembly.GetExecutingAssembly(); var callingAssembly = Assembly.GetCallingAssembly(); // auto register by interface builder.Services.AddAllInterfaceServices(thisAssembly); // load all services from this assembly builder.Services.AddAllInterfaceServices(callingAssembly); // load all services from executing assembly builder.Services.AddBlazoredLocalStorage(); // used to cache lazy loaded assemblies locally, for fast startup var resolver = new LazyAssemblyWebResolver(); var lazyBuilder = new LazyBlazorPluginBuilder(resolver); container.RegisterInstance(resolver); return(lazyBuilder); }
public LazyLoaderService(ServiceContainer container, LazyAssemblyWebResolver assemblyLocationResolver, ISyncLocalStorageService localStorage) { this.container = container; this.assemblyLocationResolver = assemblyLocationResolver; this.localStorage = localStorage; alreadyLazyLoaded = new Dictionary <string, Assembly>(); //loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies().Select(a => a.GetName().Name + ".dll").ToHashSet(); alreadyBaseLoaded = getLoadedAssemblies(); }