| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | using System.Configuration; |
| | | 6 | | using CoreWCF.Channels; |
| | | 7 | | |
| | | 8 | | namespace CoreWCF.Configuration |
| | | 9 | | { |
| | | 10 | | public sealed class TcpTransportElement : ConnectionOrientedTransportElement |
| | | 11 | | { |
| | | 12 | | public override void ApplyConfiguration(BindingElement bindingElement) |
| | | 13 | | { |
| | 2 | 14 | | base.ApplyConfiguration(bindingElement); |
| | 2 | 15 | | TcpTransportBindingElement binding = (TcpTransportBindingElement)bindingElement; |
| | 2 | 16 | | PropertyInformationCollection propertyInfo = ElementInformation.Properties; |
| | 2 | 17 | | if (ListenBacklog != TcpTransportDefaults.ListenBacklogConst) |
| | | 18 | | { |
| | 1 | 19 | | binding.ListenBacklog = ListenBacklog; |
| | | 20 | | } |
| | | 21 | | //binding.PortSharingEnabled = this.PortSharingEnabled; |
| | | 22 | | //binding.TeredoEnabled = this.TeredoEnabled; |
| | 2 | 23 | | ConnectionPoolSettings.ApplyConfiguration(binding.ConnectionPoolSettings); |
| | 2 | 24 | | binding.ExtendedProtectionPolicy = ConfigurationChannelBindingUtility.BuildPolicy(ExtendedProtectionPolicy); |
| | 2 | 25 | | } |
| | | 26 | | |
| | | 27 | | public override Type BindingElementType |
| | | 28 | | { |
| | 12 | 29 | | get { return typeof(TcpTransportBindingElement); } |
| | | 30 | | } |
| | | 31 | | |
| | | 32 | | public override void CopyFrom(ServiceModelExtensionElement from) |
| | | 33 | | { |
| | 0 | 34 | | base.CopyFrom(from); |
| | | 35 | | |
| | 0 | 36 | | TcpTransportElement source = (TcpTransportElement)from; |
| | 0 | 37 | | ListenBacklog = source.ListenBacklog; |
| | | 38 | | //this.PortSharingEnabled = source.PortSharingEnabled; |
| | | 39 | | //this.TeredoEnabled = source.TeredoEnabled; |
| | 0 | 40 | | ConnectionPoolSettings.CopyFrom(source.ConnectionPoolSettings); |
| | 0 | 41 | | ConfigurationChannelBindingUtility.CopyFrom(source.ExtendedProtectionPolicy, ExtendedProtectionPolicy); |
| | 0 | 42 | | } |
| | | 43 | | |
| | | 44 | | protected override TransportBindingElement CreateDefaultBindingElement() |
| | | 45 | | { |
| | 2 | 46 | | return new TcpTransportBindingElement(); |
| | | 47 | | } |
| | | 48 | | |
| | | 49 | | protected internal override void InitializeFrom(BindingElement bindingElement) |
| | | 50 | | { |
| | 0 | 51 | | base.InitializeFrom(bindingElement); |
| | 0 | 52 | | TcpTransportBindingElement binding = (TcpTransportBindingElement)bindingElement; |
| | | 53 | | |
| | 0 | 54 | | ConfigurationProperty listenBacklogProperty = Properties[ConfigurationStrings.ListenBacklog]; |
| | 0 | 55 | | SetPropertyValue(listenBacklogProperty, binding.ListenBacklog, false /*ignore locks*/); |
| | | 56 | | |
| | | 57 | | //SetPropertyValueIfNotDefaultValue(ConfigurationStrings.PortSharingEnabled, binding.PortSharingEnabled); |
| | | 58 | | //SetPropertyValueIfNotDefaultValue(ConfigurationStrings.TeredoEnabled, binding.TeredoEnabled); |
| | 0 | 59 | | ConnectionPoolSettings.InitializeFrom(binding.ConnectionPoolSettings); |
| | 0 | 60 | | ConfigurationChannelBindingUtility.InitializeFrom(binding.ExtendedProtectionPolicy, ExtendedProtectionPolicy |
| | 0 | 61 | | } |
| | | 62 | | |
| | | 63 | | [ConfigurationProperty(ConfigurationStrings.ListenBacklog, DefaultValue = TcpTransportDefaults.ListenBacklogCons |
| | | 64 | | [IntegerValidator(MinValue = 0)] |
| | | 65 | | public int ListenBacklog |
| | | 66 | | { |
| | 3 | 67 | | get { return (int)base[ConfigurationStrings.ListenBacklog]; } |
| | 0 | 68 | | set { base[ConfigurationStrings.ListenBacklog] = value; } |
| | | 69 | | } |
| | | 70 | | |
| | | 71 | | //[ConfigurationProperty(ConfigurationStrings.PortSharingEnabled, DefaultValue = TcpTransportDefaults.PortSharin |
| | | 72 | | //public bool PortSharingEnabled |
| | | 73 | | //{ |
| | | 74 | | // get { return (bool)base[ConfigurationStrings.PortSharingEnabled]; } |
| | | 75 | | // set { base[ConfigurationStrings.PortSharingEnabled] = value; } |
| | | 76 | | //} |
| | | 77 | | |
| | | 78 | | //[ConfigurationProperty(ConfigurationStrings.TeredoEnabled, DefaultValue = TcpTransportDefaults.TeredoEnabled)] |
| | | 79 | | //public bool TeredoEnabled |
| | | 80 | | //{ |
| | | 81 | | // get { return (bool)base[ConfigurationStrings.TeredoEnabled]; } |
| | | 82 | | // set { base[ConfigurationStrings.TeredoEnabled] = value; } |
| | | 83 | | //} |
| | | 84 | | |
| | | 85 | | [ConfigurationProperty(ConfigurationStrings.ConnectionPoolSettings)] |
| | | 86 | | public TcpConnectionPoolSettingsElement ConnectionPoolSettings |
| | | 87 | | { |
| | 2 | 88 | | get { return (TcpConnectionPoolSettingsElement)base[ConfigurationStrings.ConnectionPoolSettings]; } |
| | 0 | 89 | | set { base[ConfigurationStrings.ConnectionPoolSettings] = value; } |
| | | 90 | | } |
| | | 91 | | |
| | | 92 | | [ConfigurationProperty(ConfigurationStrings.ExtendedProtectionPolicy)] |
| | | 93 | | public ExtendedProtectionPolicyElement ExtendedProtectionPolicy |
| | | 94 | | { |
| | 2 | 95 | | get { return (ExtendedProtectionPolicyElement)base[ConfigurationStrings.ExtendedProtectionPolicy]; } |
| | 0 | 96 | | private set { base[ConfigurationStrings.ExtendedProtectionPolicy] = value; } |
| | | 97 | | } |
| | | 98 | | } |
| | | 99 | | } |