| | | 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 class NetTcpBindingElement : StandardBindingElement |
| | | 11 | | { |
| | | 12 | | public NetTcpBindingElement(string name) |
| | 10 | 13 | | : base(name) |
| | | 14 | | { |
| | 10 | 15 | | } |
| | | 16 | | |
| | | 17 | | public NetTcpBindingElement() |
| | 10 | 18 | | : this(null) |
| | | 19 | | { |
| | 10 | 20 | | } |
| | | 21 | | |
| | | 22 | | [ConfigurationProperty(ConfigurationStrings.TransactionFlow, DefaultValue = false)] |
| | | 23 | | public bool TransactionFlow |
| | | 24 | | { |
| | 0 | 25 | | get { throw new PlatformNotSupportedException(); } |
| | | 26 | | } |
| | | 27 | | |
| | | 28 | | [ConfigurationProperty(ConfigurationStrings.TransferMode, DefaultValue = TransferMode.Buffered)] |
| | | 29 | | public TransferMode TransferMode |
| | | 30 | | { |
| | 9 | 31 | | get { return (TransferMode)base[ConfigurationStrings.TransferMode]; } |
| | 0 | 32 | | set { base[ConfigurationStrings.TransferMode] = value; } |
| | | 33 | | } |
| | | 34 | | |
| | | 35 | | [ConfigurationProperty(ConfigurationStrings.TransactionProtocol, DefaultValue = "")] |
| | | 36 | | public string TransactionProtocol |
| | | 37 | | { |
| | 0 | 38 | | get { throw new PlatformNotSupportedException(); } |
| | | 39 | | } |
| | | 40 | | |
| | | 41 | | [ConfigurationProperty(ConfigurationStrings.HostNameComparisonMode, DefaultValue = HostNameComparisonMode.Strong |
| | | 42 | | public HostNameComparisonMode HostNameComparisonMode |
| | | 43 | | { |
| | 9 | 44 | | get { return (HostNameComparisonMode)base[ConfigurationStrings.HostNameComparisonMode]; } |
| | 0 | 45 | | set { base[ConfigurationStrings.HostNameComparisonMode] = value; } |
| | | 46 | | } |
| | | 47 | | |
| | | 48 | | [ConfigurationProperty(ConfigurationStrings.ListenBacklog, DefaultValue = 1)] |
| | | 49 | | [IntegerValidator(MinValue = 0)] |
| | | 50 | | public int ListenBacklog |
| | | 51 | | { |
| | 0 | 52 | | get { throw new PlatformNotSupportedException(); } |
| | | 53 | | } |
| | | 54 | | |
| | | 55 | | [ConfigurationProperty(ConfigurationStrings.MaxBufferPoolSize, DefaultValue = 1L)] |
| | | 56 | | [LongValidator(MinValue = 0)] |
| | | 57 | | public long MaxBufferPoolSize |
| | | 58 | | { |
| | 9 | 59 | | get { return (long)base[ConfigurationStrings.MaxBufferPoolSize]; } |
| | 0 | 60 | | set { base[ConfigurationStrings.MaxBufferPoolSize] = value; } |
| | | 61 | | } |
| | | 62 | | |
| | | 63 | | [ConfigurationProperty(ConfigurationStrings.MaxBufferSize, DefaultValue = 65536)] |
| | | 64 | | [IntegerValidator(MinValue = 1)] |
| | | 65 | | public int MaxBufferSize |
| | | 66 | | { |
| | 10 | 67 | | get { return (int)base[ConfigurationStrings.MaxBufferSize]; } |
| | 0 | 68 | | set { base[ConfigurationStrings.MaxBufferSize] = value; } |
| | | 69 | | } |
| | | 70 | | |
| | | 71 | | [ConfigurationProperty(ConfigurationStrings.MaxConnections, DefaultValue = 1)] |
| | | 72 | | [IntegerValidator(MinValue = 0)] |
| | | 73 | | public int MaxConnections |
| | | 74 | | { |
| | 9 | 75 | | get { return (int)base[ConfigurationStrings.MaxConnections]; } |
| | 0 | 76 | | set { base[ConfigurationStrings.MaxConnections] = value; } |
| | | 77 | | } |
| | | 78 | | |
| | | 79 | | [ConfigurationProperty(ConfigurationStrings.MaxReceivedMessageSize, DefaultValue = 65536L)] |
| | | 80 | | [LongValidator(MinValue = 1)] |
| | | 81 | | public long MaxReceivedMessageSize |
| | | 82 | | { |
| | 10 | 83 | | get { return (long)base[ConfigurationStrings.MaxReceivedMessageSize]; } |
| | 0 | 84 | | set { base[ConfigurationStrings.MaxReceivedMessageSize] = value; } |
| | | 85 | | } |
| | | 86 | | |
| | | 87 | | [ConfigurationProperty(ConfigurationStrings.PortSharingEnabled, DefaultValue = false)] |
| | | 88 | | public bool PortSharingEnabled |
| | | 89 | | { |
| | 0 | 90 | | get { throw new PlatformNotSupportedException(); } |
| | | 91 | | } |
| | | 92 | | |
| | | 93 | | [ConfigurationProperty(ConfigurationStrings.ReliableSession)] |
| | | 94 | | public string ReliableSession |
| | | 95 | | { |
| | 0 | 96 | | get { throw new PlatformNotSupportedException(); } |
| | | 97 | | } |
| | | 98 | | |
| | | 99 | | [ConfigurationProperty(ConfigurationStrings.Security)] |
| | | 100 | | public NetTcpSecurityElement Security |
| | | 101 | | { |
| | 18 | 102 | | get { return (NetTcpSecurityElement)base[ConfigurationStrings.Security]; } |
| | | 103 | | } |
| | | 104 | | |
| | | 105 | | [ConfigurationProperty(ConfigurationStrings.ReaderQuotas)] |
| | | 106 | | public XmlDictionaryReaderQuotasElement ReaderQuotas |
| | | 107 | | { |
| | 10 | 108 | | get { return (XmlDictionaryReaderQuotasElement)base[ConfigurationStrings.ReaderQuotas]; } |
| | | 109 | | } |
| | | 110 | | |
| | | 111 | | public override Binding CreateBinding() |
| | | 112 | | { |
| | 9 | 113 | | var binding = new NetTcpBinding(Security.Mode) |
| | 9 | 114 | | { |
| | 9 | 115 | | Name = Name, |
| | 9 | 116 | | MaxReceivedMessageSize = MaxReceivedMessageSize, |
| | 9 | 117 | | MaxBufferSize = MaxBufferSize, |
| | 9 | 118 | | MaxBufferPoolSize = MaxBufferPoolSize, |
| | 9 | 119 | | MaxConnections = MaxConnections, |
| | 9 | 120 | | ReceiveTimeout = ReceiveTimeout, |
| | 9 | 121 | | OpenTimeout = OpenTimeout, |
| | 9 | 122 | | CloseTimeout = CloseTimeout, |
| | 9 | 123 | | SendTimeout = SendTimeout, |
| | 9 | 124 | | ReaderQuotas = ReaderQuotas.Clone(), |
| | 9 | 125 | | TransferMode = TransferMode, |
| | 9 | 126 | | HostNameComparisonMode = HostNameComparisonMode |
| | 9 | 127 | | }; |
| | | 128 | | |
| | | 129 | | //this.ReliableSession.ApplyConfiguration(nptBinding.ReliableSession); |
| | 9 | 130 | | Security.ApplyConfiguration(binding.Security); |
| | 9 | 131 | | return binding; |
| | | 132 | | } |
| | | 133 | | } |
| | | 134 | | } |