public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder, WebAppEngineConfig config) { //注册 PooledRedisClientManager builder.Register<IRedisClientsManager>(c => new PooledRedisClientManager("127.0.0.1", "127.0.0.1") { ConnectTimeout = 100, }); }
public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder, WebAppEngineConfig config) { //register data repository assembly if (!string.IsNullOrWhiteSpace(config.Data)) { var dataAssembly = Assembly.Load(config.Data); //builder = new ContainerBuilder(); builder.RegisterGeneric(dataAssembly.GetType(config.DataType)).As(typeof(IRepository<>)).InstancePerLifetimeScope(); //builder.Update(container); } //register serives assembly if (!string.IsNullOrWhiteSpace(config.Service)) { var serviceAssembly = Assembly.Load(config.Service); //builder = new ContainerBuilder(); builder.RegisterAssemblyTypes(serviceAssembly).Where(t => t.Name.EndsWith("Service")).AsImplementedInterfaces().InstancePerLifetimeScope(); //builder.Update(container); } }
/// <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) { var config = new WebAppEngineConfig(); var dynamicDiscoveryNode = section.SelectSingleNode("DynamicDiscovery"); if (dynamicDiscoveryNode != null && dynamicDiscoveryNode.Attributes != null) { var attribute = dynamicDiscoveryNode.Attributes["Enabled"]; if (attribute != null) config.DynamicDiscovery = Convert.ToBoolean(attribute.Value); } var dataNode = section.SelectSingleNode("Data"); if (dataNode != null && dataNode.Attributes != null) { var attribute = dataNode.Attributes["Assembly"]; if (attribute != null) config.Data = attribute.Value; attribute = dataNode.Attributes["Type"]; if (attribute != null) config.DataType = attribute.Value; } var serviceNode = section.SelectSingleNode("Service"); if (serviceNode != null && serviceNode.Attributes != null) { var attribute = serviceNode.Attributes["Assembly"]; if (attribute != null) config.Service = attribute.Value; } var engineNode = section.SelectSingleNode("Engine"); if (engineNode != null && engineNode.Attributes != null) { var attribute = engineNode.Attributes["Type"]; if (attribute != null) config.EngineType = attribute.Value; } var startupNode = section.SelectSingleNode("Startup"); if (startupNode != null && startupNode.Attributes != null) { var attribute = startupNode.Attributes["IgnoreStartupTasks"]; if (attribute != null) config.IgnoreStartupTasks = Convert.ToBoolean(attribute.Value); } var themeNode = section.SelectSingleNode("Themes"); if (themeNode != null && themeNode.Attributes != null) { var attribute = themeNode.Attributes["basePath"]; if (attribute != null) config.ThemeBasePath = attribute.Value; } var userAgentStringsNode = section.SelectSingleNode("UserAgentStrings"); if (userAgentStringsNode != null && userAgentStringsNode.Attributes != null) { var attribute = userAgentStringsNode.Attributes["databasePath"]; if (attribute != null) config.UserAgentStringsPath = attribute.Value; } return config; }