コード例 #1
0
        public static BrokerConfigurationSection FromXml(XElement element)
        {
            var section = new BrokerConfigurationSection();

            section.DeserializeSection(element.CreateReader());
            return(section);
        }
コード例 #2
0
        /// <summary>
        /// Read configuration from BrokerConfigurationSection
        /// </summary>
        public static BrokerConfiguration FromConfigurationSection(BrokerConfigurationSection section)
        {
            var config = new BrokerConfiguration();

            if (!String.IsNullOrWhiteSpace(section.StorageDirectory.Value))
            {
                config.StorageDirectory = section.StorageDirectory.Value;
            }

            if (section.BrokerId.Value != 0)
            {
                config.BrokerId = section.BrokerId.Value;
            }

            if (!String.IsNullOrWhiteSpace(section.HostName.Value))
            {
                config.HostName = section.HostName.Value;
            }

            if (section.Port.Value != 0)
            {
                config.Port = section.Port.Value;
            }

            if (section.PullPort.Value != 0)
            {
                config.PullPort = section.PullPort.Value;
            }

            if (section.NumberOfPartitions.Value != 0)
            {
                config.NumberOfPartitions = section.NumberOfPartitions.Value;
            }

            if (section.NumberOfPartitionsPerTopic != null)
            {
                foreach (var element in section.NumberOfPartitionsPerTopic)
                {
                    var item = (TopicElement)element;
                    config.NumberOfPartitionsPerTopic.Add(item.Topic, item.Partitions);
                }
            }

            return(config);
        }