/// <summary> /// Creates a factory instance and adds a http application injecting facility. /// </summary> /// <returns>A new factory</returns> public static IEngine CreateEngineInstance(NopConfig config) { if (config != null && !string.IsNullOrEmpty(config.EngineType)) { var engineType = Type.GetType(config.EngineType); if (engineType == null) throw new ConfigurationErrorsException("The type '" + engineType + "' could not be found. Please check the configuration at /configuration/nop/engine[@engineType] or check for missing assemblies."); if (!typeof(IEngine).IsAssignableFrom(engineType)) throw new ConfigurationErrorsException("The type '" + engineType + "' doesn't implement 'Nop.Core.Infrastructure.IEngine' and cannot be configured in /configuration/nop/engine[@engineType] for that purpose."); return Activator.CreateInstance(engineType) as IEngine; } throw new Exception("初始化Engine 出错"); }
/// <summary> /// Creates a configuration section handler. /// </summary> /// <param name="parent">Parent object.</param> /// <param name="configContext">Configuration context object.</param> /// <param name="section">Section XML node.</param> /// <returns>The created section handler object.</returns> public object Create(object parent, object configContext, XmlNode section) { NopConfig config = new NopConfig(); //var sqlServerNode = section.SelectSingleNode("SqlServer"); //if (sqlServerNode != null) //{ // XmlAttribute attribute = sqlServerNode.Attributes["ConnectionStringName"]; // if ((attribute != null) && (WebConfigurationManager.ConnectionStrings[attribute.Value] != null)) // config.ConnectionString = WebConfigurationManager.ConnectionStrings[attribute.Value].ConnectionString; //} var dynamicDiscoveryNode = section.SelectSingleNode("DynamicDiscovery"); if (dynamicDiscoveryNode != null) { var attribute = dynamicDiscoveryNode.Attributes["Enabled"]; if (attribute != null) config.DynamicDiscovery = Convert.ToBoolean(attribute.Value); } var engineNode = section.SelectSingleNode("Engine"); if (engineNode != null) { var attribute = engineNode.Attributes["Type"]; if (attribute != null) config.EngineType = attribute.Value; } var themeNode = section.SelectSingleNode("Themes"); if (themeNode != null) { var attribute = themeNode.Attributes["basePath"]; if (attribute != null) config.ThemeBasePath = attribute.Value; } config.ScheduleTasks = section.SelectSingleNode("ScheduleTasks"); return config; }
public WebAppTypeFinder(IWebHelper webHelper, NopConfig config) { this._webHelper = webHelper; this._ensureBinFolderAssembliesLoaded = config.DynamicDiscovery; //this_.ensurePluginFolderAssembliesLoaded = config.DynamicDiscovery; }