1 //------------------------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //------------------------------------------------------------------------------
5 namespace System.ServiceModel.Configuration
7 using System.Configuration;
8 using System.ServiceModel.Channels;
9 using System.ServiceModel;
11 public sealed partial class OneWayElement : BindingElementExtensionElement
13 public OneWayElement()
17 public override Type BindingElementType
19 get { return typeof(OneWayBindingElement); }
22 [ConfigurationProperty(ConfigurationStrings.ChannelPoolSettings)]
23 public ChannelPoolSettingsElement ChannelPoolSettings
25 get { return (ChannelPoolSettingsElement)base[ConfigurationStrings.ChannelPoolSettings]; }
28 [ConfigurationProperty(ConfigurationStrings.MaxAcceptedChannels, DefaultValue = OneWayDefaults.MaxAcceptedChannels)]
29 [IntegerValidator(MinValue = 1)]
30 public int MaxAcceptedChannels
32 get { return (int)base[ConfigurationStrings.MaxAcceptedChannels]; }
33 set { base[ConfigurationStrings.MaxAcceptedChannels] = value; }
36 [ConfigurationProperty(ConfigurationStrings.PacketRoutable, DefaultValue = OneWayDefaults.PacketRoutable)]
37 public bool PacketRoutable
39 get { return (bool)base[ConfigurationStrings.PacketRoutable]; }
40 set { base[ConfigurationStrings.PacketRoutable] = value; }
43 public override void ApplyConfiguration(BindingElement bindingElement)
45 base.ApplyConfiguration(bindingElement);
46 OneWayBindingElement oneWayBindingElement = (OneWayBindingElement)bindingElement;
47 PropertyInformationCollection propertyInfo = this.ElementInformation.Properties;
48 if (propertyInfo[ConfigurationStrings.ChannelPoolSettings].ValueOrigin != PropertyValueOrigin.Default)
50 #pragma warning suppress 56506 // Microsoft, base.ApplyConfiguration() validates the argument
51 this.ChannelPoolSettings.ApplyConfiguration(oneWayBindingElement.ChannelPoolSettings);
53 oneWayBindingElement.MaxAcceptedChannels = this.MaxAcceptedChannels;
54 oneWayBindingElement.PacketRoutable = this.PacketRoutable;
57 public override void CopyFrom(ServiceModelExtensionElement from)
61 OneWayElement source = (OneWayElement)from;
62 #pragma warning suppress 56506 // Microsoft, base.CopyFrom() validates the argument
63 PropertyInformationCollection propertyInfo = source.ElementInformation.Properties;
64 if (propertyInfo[ConfigurationStrings.ChannelPoolSettings].ValueOrigin != PropertyValueOrigin.Default)
66 this.ChannelPoolSettings.CopyFrom(source.ChannelPoolSettings);
68 this.MaxAcceptedChannels = source.MaxAcceptedChannels;
69 this.PacketRoutable = source.PacketRoutable;
72 protected internal override void InitializeFrom(BindingElement bindingElement)
74 base.InitializeFrom(bindingElement);
75 OneWayBindingElement source = (OneWayBindingElement)bindingElement;
76 this.ChannelPoolSettings.InitializeFrom(source.ChannelPoolSettings);
77 SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxAcceptedChannels, source.MaxAcceptedChannels);
78 SetPropertyValueIfNotDefaultValue(ConfigurationStrings.PacketRoutable, source.PacketRoutable);
81 protected internal override BindingElement CreateBindingElement()
83 OneWayBindingElement result = new OneWayBindingElement();
84 this.ApplyConfiguration(result);