1 //------------------------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //------------------------------------------------------------------------------
5 namespace System.ServiceModel.Configuration
8 using System.Configuration;
9 using System.ServiceModel;
10 using System.ServiceModel.Channels;
12 [ObsoleteAttribute ("PeerChannel feature is obsolete and will be removed in the future.", false)]
13 public partial class PeerTransportElement : BindingElementExtensionElement
15 public PeerTransportElement()
19 public override Type BindingElementType
21 get { return typeof(PeerTransportBindingElement); }
24 [ConfigurationProperty(ConfigurationStrings.ListenIPAddress, DefaultValue = PeerTransportDefaults.ListenIPAddress)]
25 [System.ComponentModel.TypeConverter(typeof(PeerTransportListenAddressConverter))]
26 [PeerTransportListenAddressValidator()]
27 public IPAddress ListenIPAddress
29 get { return (IPAddress)base[ConfigurationStrings.ListenIPAddress]; }
30 set { base[ConfigurationStrings.ListenIPAddress] = value; }
33 [ConfigurationProperty(ConfigurationStrings.MaxBufferPoolSize, DefaultValue = TransportDefaults.MaxBufferPoolSize)]
34 [LongValidator(MinValue = 1)]
35 public long MaxBufferPoolSize
37 get { return (long)base[ConfigurationStrings.MaxBufferPoolSize]; }
38 set { base[ConfigurationStrings.MaxBufferPoolSize] = value; }
41 [ConfigurationProperty(ConfigurationStrings.MaxReceivedMessageSize, DefaultValue = TransportDefaults.MaxReceivedMessageSize)]
42 [LongValidator(MinValue = 1)]
43 public long MaxReceivedMessageSize
45 get { return (long)base[ConfigurationStrings.MaxReceivedMessageSize]; }
46 set { base[ConfigurationStrings.MaxReceivedMessageSize] = value; }
49 [ConfigurationProperty(ConfigurationStrings.Port, DefaultValue = PeerTransportDefaults.Port)]
50 [IntegerValidator(MinValue = PeerTransportConstants.MinPort, MaxValue = PeerTransportConstants.MaxPort)]
53 get { return (int)base[ConfigurationStrings.Port]; }
54 set { base[ConfigurationStrings.Port] = value; }
57 [ConfigurationProperty(ConfigurationStrings.Security)]
58 public PeerSecurityElement Security
60 get { return (PeerSecurityElement)base[ConfigurationStrings.Security]; }
63 public override void ApplyConfiguration(BindingElement bindingElement)
65 base.ApplyConfiguration(bindingElement);
66 PeerTransportBindingElement binding = (PeerTransportBindingElement)bindingElement;
67 binding.ListenIPAddress = this.ListenIPAddress;
68 binding.Port = this.Port;
69 binding.MaxBufferPoolSize = this.MaxBufferPoolSize;
70 binding.MaxReceivedMessageSize = this.MaxReceivedMessageSize;
71 #pragma warning suppress 56506 //Microsoft; base.ApplyConfiguration() checks for 'binding' being null
72 this.Security.ApplyConfiguration(binding.Security);
75 public override void CopyFrom(ServiceModelExtensionElement from)
79 PeerTransportElement source = (PeerTransportElement)from;
80 #pragma warning suppress 56506 // Microsoft, base.CopyFrom() validates the argument
81 this.ListenIPAddress = source.ListenIPAddress;
82 this.Port = source.Port;
83 this.MaxBufferPoolSize = source.MaxBufferPoolSize;
84 this.MaxReceivedMessageSize = source.MaxReceivedMessageSize;
85 this.Security.CopyFrom(source.Security);
88 protected internal override BindingElement CreateBindingElement()
90 PeerTransportBindingElement binding = new PeerTransportBindingElement();
91 this.ApplyConfiguration(binding);
95 protected internal override void InitializeFrom(BindingElement bindingElement)
97 base.InitializeFrom(bindingElement);
98 PeerTransportBindingElement binding = (PeerTransportBindingElement)bindingElement;
99 SetPropertyValueIfNotDefaultValue(ConfigurationStrings.ListenIPAddress, binding.ListenIPAddress);
100 SetPropertyValueIfNotDefaultValue(ConfigurationStrings.Port, binding.Port);
101 SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxBufferPoolSize, binding.MaxBufferPoolSize);
102 SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxReceivedMessageSize, binding.MaxReceivedMessageSize);
103 this.Security.InitializeFrom(binding.Security);