NetTcpSection.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //-----------------------------------------------------------------------------
  4. namespace System.ServiceModel.Activation.Configuration
  5. {
  6. using System;
  7. using System.Configuration;
  8. using System.ServiceModel.Channels;
  9. using System.ServiceModel.Configuration;
  10. public sealed partial class NetTcpSection : ConfigurationSection
  11. {
  12. PropertyInformationCollection propertyInfo;
  13. public NetTcpSection()
  14. : base()
  15. {
  16. propertyInfo = this.ElementInformation.Properties;
  17. }
  18. [ConfigurationProperty(ConfigurationStrings.AllowAccounts)]
  19. public SecurityIdentifierElementCollection AllowAccounts
  20. {
  21. get { return (SecurityIdentifierElementCollection)base[ConfigurationStrings.AllowAccounts]; }
  22. }
  23. static internal NetTcpSection GetSection()
  24. {
  25. NetTcpSection retval = (NetTcpSection)ConfigurationManager.GetSection(ConfigurationStrings.NetTcpSectionPath);
  26. if (retval == null)
  27. {
  28. retval = new NetTcpSection();
  29. }
  30. return retval;
  31. }
  32. protected override void InitializeDefault()
  33. {
  34. this.AllowAccounts.SetDefaultIdentifiers();
  35. }
  36. [ConfigurationProperty(ConfigurationStrings.ListenBacklog, DefaultValue = ListenerConstants.DefaultListenBacklog)]
  37. [IntegerValidator(MinValue = 0)]
  38. public int ListenBacklog
  39. {
  40. get
  41. {
  42. int listenBacklog = (int)base[ConfigurationStrings.ListenBacklog];
  43. if (listenBacklog != ListenerConstants.DefaultListenBacklog)
  44. {
  45. // if the user changed the default, return user's value
  46. return listenBacklog;
  47. }
  48. else
  49. {
  50. // otherwise return the transport default
  51. return TcpTransportDefaults.GetListenBacklog();
  52. }
  53. }
  54. set { base[ConfigurationStrings.ListenBacklog] = value; }
  55. }
  56. [ConfigurationProperty(ConfigurationStrings.MaxPendingConnections, DefaultValue = ListenerConstants.DefaultMaxPendingConnections)]
  57. [IntegerValidator(MinValue = 0)]
  58. public int MaxPendingConnections
  59. {
  60. get { return (int)base[ConfigurationStrings.MaxPendingConnections]; }
  61. set { base[ConfigurationStrings.MaxPendingConnections] = value; }
  62. }
  63. [ConfigurationProperty(ConfigurationStrings.MaxPendingAccepts, DefaultValue = ListenerConstants.DefaultMaxPendingAccepts)]
  64. [IntegerValidator(MinValue = 0)]
  65. public int MaxPendingAccepts
  66. {
  67. get
  68. {
  69. int maxPendingAccepts = (int)base[ConfigurationStrings.MaxPendingAccepts];
  70. if (maxPendingAccepts != ListenerConstants.DefaultMaxPendingAccepts)
  71. {
  72. // if the user changed the default, return user's value
  73. return maxPendingAccepts;
  74. }
  75. else
  76. {
  77. // otherwise return 2 * transport default, since SMSvcHost defaults are global
  78. return 2 * ConnectionOrientedTransportDefaults.GetMaxPendingAccepts();
  79. }
  80. }
  81. set { base[ConfigurationStrings.MaxPendingAccepts] = value; }
  82. }
  83. [ConfigurationProperty(ConfigurationStrings.ReceiveTimeout, DefaultValue = ListenerConstants.DefaultReceiveTimeoutString)]
  84. [System.ComponentModel.TypeConverter(typeof(TimeSpanOrInfiniteConverter))]
  85. [System.ServiceModel.Configuration.ServiceModelTimeSpanValidator(MinValueString = ConfigurationStrings.TimeSpanZero)]
  86. public TimeSpan ReceiveTimeout
  87. {
  88. get { return (TimeSpan)base[ConfigurationStrings.ReceiveTimeout]; }
  89. set { base[ConfigurationStrings.ReceiveTimeout] = value; }
  90. }
  91. [ConfigurationProperty(ConfigurationStrings.TeredoEnabled, DefaultValue = ListenerConstants.DefaultTeredoEnabled)]
  92. public bool TeredoEnabled
  93. {
  94. get { return (bool)base[ConfigurationStrings.TeredoEnabled]; }
  95. set { base[ConfigurationStrings.TeredoEnabled] = value; }
  96. }
  97. }
  98. }