/// <summary> /// Tries to attach available module assemblies from working modules directory. /// </summary> public void AddUploadedModules() { if (Log.IsTraceEnabled) { Log.Trace("Add uploaded Better Cms modules."); } var availableModuleFiles = workingDirectory.GetAvailableModules(); var runtimeModuleFiles = new List <FileInfo>(); foreach (var moduleInfo in availableModuleFiles) { try { var runtimeModuleInfo = workingDirectory.RecopyModulesToRuntimeFolder(moduleInfo); runtimeModuleFiles.Add(runtimeModuleInfo); } catch (Exception ex) { throw new CmsException("Failed to recopy module " + moduleInfo.FullName + ".", ex); } } foreach (var runtimeModuleFile in runtimeModuleFiles) { try { if (runtimeModuleFile.FullName.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)) { var runtimeModuleAssembly = assemblyLoader.Load(AssemblyName.GetAssemblyName(runtimeModuleFile.FullName)); BuildManager.AddReferencedAssembly(runtimeModuleAssembly); embeddedResourcesProvider.AddEmbeddedResourcesFrom(runtimeModuleAssembly); modulesRegistration.AddModuleDescriptorTypeFromAssembly(runtimeModuleAssembly); } } catch (Exception ex) { throw new CmsException("Failed to add reference to runtime module " + runtimeModuleFile.FullName + ".", ex); } } }
private static ILifetimeScope CreateContainer() { ContainerBuilder updater = CmsContext.InitializeContainer(); updater.RegisterType <StubMappingResolver>().As <IMappingResolver>(); ContextScopeProvider.RegisterTypes(updater); var container = ContextScopeProvider.CreateChildContainer(); IModulesRegistration modulesRegistration = container.Resolve <IModulesRegistration>(); foreach (var knownAssembly in KnownAssemblies) { modulesRegistration.AddModuleDescriptorTypeFromAssembly(knownAssembly); } modulesRegistration.InitializeModules(); return(container); }
/// <summary> /// Adds the uploaded module. /// </summary> /// <param name="assembly">The assembly.</param> public virtual void AddUploadedModule(Assembly assembly) { modulesRegistration.AddModuleDescriptorTypeFromAssembly(assembly); }