private void EnsureModulesDiscovered()
        {
            ModulesConfigurationSection section = this.Store.RetrieveModuleConfigurationSection();

            if (section != null)
            {
                foreach (ModuleConfigurationElement element in section.Modules)
                {
                    IList <string> dependencies = new List <string>();

                    if (element.Dependencies.Count > 0)
                    {
                        foreach (ModuleDependencyConfigurationElement dependency in element.Dependencies)
                        {
                            dependencies.Add(dependency.ModuleName);
                        }
                    }

                    ModuleInfo moduleInfo = new ModuleInfo(element.ModuleName, element.ModuleType)
                    {
                        Ref = GetFileAbsoluteUri(element.AssemblyFile),
                        InitializationMode = element.StartupLoaded ? InitializationMode.WhenAvailable : InitializationMode.OnDemand
                    };
                    moduleInfo.DependsOn.AddRange(dependencies.ToArray());
                    AddModule(moduleInfo);
                }
            }
        }
        private void EnsureModulesDiscovered()
        {
            if (_modules == null)
            {
                _modules = new List <ModuleInfo>();

                ModulesConfigurationSection section = _store.RetrieveModuleConfigurationSection();

                if (section != null)
                {
                    foreach (ModuleConfigurationElement element in section.Modules)
                    {
                        IList <string> dependencies = new List <string>();

                        if (element.Dependencies.Count > 0)
                        {
                            foreach (ModuleDependencyConfigurationElement dependency in element.Dependencies)
                            {
                                dependencies.Add(dependency.ModuleName);
                            }
                        }

                        ModuleInfo moduleInfo = new ModuleInfo(element.AssemblyFile, element.ModuleType,
                                                               element.ModuleName,
                                                               element.StartupLoaded, dependencies.ToArray());
                        _modules.Add(moduleInfo);
                    }
                }
            }
        }
示例#3
0
        /// <summary>
        /// Gets the module configuration data.
        /// </summary>
        /// <returns>A <see cref="ModulesConfigurationSection"/> instance.</returns>
        public virtual ModulesConfigurationSection RetrieveModuleConfigurationSection()
        {
            foreach (string fileName in Directory.GetFiles(_baseDirectory, "*.config", SearchOption.TopDirectoryOnly))
            {
                System.Configuration.Configuration configuration =
                    GetConfiguration(Path.Combine(_baseDirectory, fileName));

                ModulesConfigurationSection section = (ModulesConfigurationSection)configuration.GetSection("modules");

                if (section != null)
                {
                    return(section);
                }
            }

            return(null);
        }