예제 #1
0
파일: BindingConfig.cs 프로젝트: lcksy/Dot
        private void AddSetting(BindingSetting setting)
        {
            Dictionary <string, BindingSetting> keyValue;

            if (!this.Settings.TryGetValue(setting.BindingType, out keyValue))
            {
                keyValue = new Dictionary <string, BindingSetting>();
                this.Settings.Add(setting.BindingType, keyValue);
            }

            if (!keyValue.ContainsKey(setting.Name))
            {
                keyValue.Add(setting.Name, setting);
            }
        }
예제 #2
0
파일: BindingConfig.cs 프로젝트: lcksy/Dot
        public object Create(object parent, object configContext, XmlNode section)
        {
            var config = new BindingConfig();

            var bindingNodes = section.SelectNodes("binding");

            foreach (XmlNode bindingNode in bindingNodes)
            {
                var  bindingTypeNick = bindingNode.GetAttributeValue("bindingType").ToLower();
                Type bindingType;
                if (!BINDING_NAMES.TryGetValue(bindingTypeNick, out bindingType))
                {
                    continue;
                }

                var maxReceivedMessageSize = Convert.ToInt64(bindingNode.GetAttributeValue("messageSize", int.MaxValue.ToString()));
                var maxBufferSize          = Convert.ToInt32(bindingNode.GetAttributeValue("bufferSize", int.MaxValue.ToString()));
                var maxBufferPoolSize      = Convert.ToInt64(bindingNode.GetAttributeValue("bufferPoolSize", int.MaxValue.ToString()));
                var sendTimeout            = TimeSpan.FromMilliseconds(Convert.ToInt32(bindingNode.GetAttributeValue("sendTimeout", "6000")));
                var openTimeout            = TimeSpan.FromMilliseconds(Convert.ToInt32(bindingNode.GetAttributeValue("openTimeout", "6000")));

                var names = bindingNode.GetAttributeValue("name").Split(',', true).Distinct();
                foreach (var name in names)
                {
                    var setting = new BindingSetting
                    {
                        BindingType            = bindingType,
                        Name                   = name,
                        MaxReceivedMessageSize = maxReceivedMessageSize,
                        MaxBufferSize          = maxBufferSize,
                        MaxBufferPoolSize      = maxBufferPoolSize,
                        SendTimeout            = sendTimeout,
                        OpenTimeout            = openTimeout
                    };

                    config.AddSetting(setting);
                }
            }

            return(config);
        }