public IConfigurationSettingItem Parse(IConfiguration configuration)
        {
            var setting    = new RabbitConfigurationSetting();
            var configNode = configuration.GetSection("config");

            if (configNode.Exists())
            {
                var serializerType = configNode["serializerType"];
                if (!string.IsNullOrEmpty(serializerType))
                {
                    setting.SerializerType = serializerType.ParseType();
                }

                setting.Server         = configNode["server"];
                setting.Port           = configNode["port"].To <int>(-1);
                setting.UserName       = configNode["userName"];
                setting.Password       = configNode["password"];
                setting.ExchangeType   = configNode["exchangeType"];
                setting.VirtualHost    = configNode["virtualHost"];
                setting.RetryDelayTime = configNode["retryDelayTime"].ToTimeSpan(TimeSpan.FromSeconds(20));
                setting.RetryTimes     = configNode["retryTimes"].To <int?>();
            }

            return(setting);
        }
        public IConfigurationSettingItem Parse(XmlNode section)
        {
            var setting    = new RabbitConfigurationSetting();
            var configNode = section.SelectSingleNode("config");

            if (configNode != null)
            {
                var serializerType = configNode.GetAttributeValue("serializerType");
                if (!string.IsNullOrEmpty(serializerType))
                {
                    setting.SerializerType = serializerType.ParseType();
                }

                setting.Server         = configNode.GetAttributeValue("server");
                setting.Port           = configNode.GetAttributeValue <int>("port", -1);
                setting.UserName       = configNode.GetAttributeValue("userName");
                setting.Password       = configNode.GetAttributeValue("password");
                setting.ExchangeType   = configNode.GetAttributeValue("exchangeType");
                setting.VirtualHost    = configNode.GetAttributeValue("virtualHost");
                setting.RetryDelayTime = configNode.GetAttributeValue("retryDelayTime").ToTimeSpan(TimeSpan.FromSeconds(20));
                setting.RetryTimes     = configNode.GetAttributeValue("retryTimes").To <int?>();
            }

            return(setting);
        }
Esempio n. 3
0
        public IConfigurationSettingItem Parse(IConfiguration configuration)
        {
            var setting    = new RabbitConfigurationSetting();
            var configNode = configuration.GetSection("config");

            if (configNode.Exists())
            {
                var serializerType = configNode["serializerType"];
                if (!string.IsNullOrEmpty(serializerType))
                {
                    setting.SerializerType = serializerType.ParseType();
                }

                setting.Server   = configNode["server"];
                setting.UserName = configNode["userName"];
                setting.Password = configNode["password"];
            }

            return(setting);
        }
Esempio n. 4
0
        public IConfigurationSettingItem Parse(XmlNode section)
        {
            var setting    = new RabbitConfigurationSetting();
            var configNode = section.SelectSingleNode("config");

            if (configNode != null)
            {
                var serializerType = configNode.GetAttributeValue("serializerType");
                if (!string.IsNullOrEmpty(serializerType))
                {
                    setting.SerializerType = serializerType.ParseType();
                }

                setting.Server   = configNode.GetAttributeValue("server");
                setting.UserName = configNode.GetAttributeValue("userName");
                setting.Password = configNode.GetAttributeValue("password");
            }

            return(setting);
        }
Esempio n. 5
0
        /// <summary>
        /// 初始化 <see cref="SubscribeManager"/> 类的新实例。
        /// </summary>
        /// <param name="serviceProvider"></param>
        /// <param name="options"></param>
        public SubscribeManager(IServiceProvider serviceProvider, IOptionsMonitor <RabbitOptions> options)
            : this(serviceProvider)
        {
            var optValue = options.CurrentValue;
            if (!optValue.IsConfigured())
            {
                return;
            }

            RabbitConfigurationSetting setting = null;
            if (!string.IsNullOrEmpty(optValue.ConfigName))
            {
                var section = ConfigurationUnity.GetSection <SubscribeConfigurationSection>();
                if (section != null && section.GetSetting(optValue.ConfigName) is ExtendConfigurationSetting extSetting)
                {
                    setting = (RabbitConfigurationSetting)extSetting.Extend;
                }
            }
            else
            {
                setting = new RabbitConfigurationSetting
                {
                    Server         = optValue.Server,
                    Port           = optValue.Port ?? -1,
                    Password       = optValue.Password,
                    UserName       = optValue.UserName,
                    ExchangeType   = optValue.ExchangeType,
                    VirtualHost    = optValue.VirtualHost,
                    RetryDelayTime = optValue.RetryDelayTime,
                    RetryTimes     = optValue.RetryTimes
                };
            }

            if (setting != null)
            {
                (this as IConfigurationSettingHostService).Attach(setting);
            }

            optValue.Initializer?.Invoke(this);
        }
Esempio n. 6
0
 void IConfigurationSettingHostService.Attach(IConfigurationSettingItem setting)
 {
     this.setting = (RabbitConfigurationSetting)setting;
 }
Esempio n. 7
0
 void IConfigurationSettingHostService.Attach(IConfigurationSettingItem setting)
 {
     Setting = (RabbitConfigurationSetting)setting;
     StartPersistentTimer();
 }