WebMessageEncodingElement.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. //
  2. // WebMessageEncodingElement.cs
  3. //
  4. // Author:
  5. // Atsushi Enomoto <[email protected]>
  6. //
  7. // Copyright (C) 2008 Novell, Inc. http://www.novell.com
  8. //
  9. // Permission is hereby granted, free of charge, to any person obtaining
  10. // a copy of this software and associated documentation files (the
  11. // "Software"), to deal in the Software without restriction, including
  12. // without limitation the rights to use, copy, modify, merge, publish,
  13. // distribute, sublicense, and/or sell copies of the Software, and to
  14. // permit persons to whom the Software is furnished to do so, subject to
  15. // the following conditions:
  16. //
  17. // The above copyright notice and this permission notice shall be
  18. // included in all copies or substantial portions of the Software.
  19. //
  20. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  21. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  23. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  24. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  25. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  26. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27. //
  28. using System;
  29. using System.Collections;
  30. using System.Collections.Generic;
  31. using System.Collections.ObjectModel;
  32. using System.ComponentModel;
  33. using System.Configuration;
  34. using System.Net;
  35. using System.Net.Security;
  36. using System.Reflection;
  37. using System.ServiceModel;
  38. using System.ServiceModel.Channels;
  39. using System.ServiceModel.Description;
  40. using System.ServiceModel.Diagnostics;
  41. using System.ServiceModel.Dispatcher;
  42. using System.Runtime.Serialization;
  43. using System.Text;
  44. using System.Xml;
  45. namespace System.ServiceModel.Configuration
  46. {
  47. [MonoTODO]
  48. public sealed partial class WebMessageEncodingElement
  49. : BindingElementExtensionElement
  50. {
  51. // Static Fields
  52. static ConfigurationPropertyCollection properties;
  53. static ConfigurationProperty binding_element_type;
  54. static ConfigurationProperty max_read_pool_size;
  55. static ConfigurationProperty max_write_pool_size;
  56. static ConfigurationProperty reader_quotas;
  57. static ConfigurationProperty write_encoding;
  58. static ConfigurationProperty web_content_type_mapper_type;
  59. static WebMessageEncodingElement ()
  60. {
  61. properties = new ConfigurationPropertyCollection ();
  62. binding_element_type = new ConfigurationProperty ("",
  63. typeof (Type), null, new TypeConverter (), null,
  64. ConfigurationPropertyOptions.None);
  65. max_read_pool_size = new ConfigurationProperty ("maxReadPoolSize",
  66. typeof (int), "64", null/* FIXME: get converter for int*/, null,
  67. ConfigurationPropertyOptions.None);
  68. max_write_pool_size = new ConfigurationProperty ("maxWritePoolSize",
  69. typeof (int), "16", null/* FIXME: get converter for int*/, null,
  70. ConfigurationPropertyOptions.None);
  71. reader_quotas = new ConfigurationProperty ("readerQuotas",
  72. typeof (XmlDictionaryReaderQuotasElement), null, null/* FIXME: get converter for XmlDictionaryReaderQuotasElement*/, null,
  73. ConfigurationPropertyOptions.None);
  74. write_encoding = new ConfigurationProperty ("writeEncoding",
  75. typeof (Encoding), "utf-8", null/* FIXME: get converter for Encoding*/, null,
  76. ConfigurationPropertyOptions.None);
  77. web_content_type_mapper_type = new ConfigurationProperty ("",
  78. typeof (string), null, null /* FIXME: supply */, null,
  79. ConfigurationPropertyOptions.None);
  80. properties.Add (binding_element_type);
  81. properties.Add (max_read_pool_size);
  82. properties.Add (max_write_pool_size);
  83. properties.Add (reader_quotas);
  84. properties.Add (write_encoding);
  85. properties.Add (web_content_type_mapper_type);
  86. }
  87. public WebMessageEncodingElement ()
  88. {
  89. }
  90. // Properties
  91. public override Type BindingElementType {
  92. get { return (Type) base [binding_element_type]; }
  93. }
  94. [ConfigurationProperty ("maxReadPoolSize",
  95. Options = ConfigurationPropertyOptions.None,
  96. DefaultValue = "64")]
  97. [IntegerValidator ( MinValue = 1,
  98. MaxValue = int.MaxValue,
  99. ExcludeRange = false)]
  100. public int MaxReadPoolSize {
  101. get { return (int) base [max_read_pool_size]; }
  102. set { base [max_read_pool_size] = value; }
  103. }
  104. [ConfigurationProperty ("maxWritePoolSize",
  105. Options = ConfigurationPropertyOptions.None,
  106. DefaultValue = "16")]
  107. [IntegerValidator ( MinValue = 1,
  108. MaxValue = int.MaxValue,
  109. ExcludeRange = false)]
  110. public int MaxWritePoolSize {
  111. get { return (int) base [max_write_pool_size]; }
  112. set { base [max_write_pool_size] = value; }
  113. }
  114. [ConfigurationProperty ("readerQuotas",
  115. Options = ConfigurationPropertyOptions.None)]
  116. public XmlDictionaryReaderQuotasElement ReaderQuotas {
  117. get { return (XmlDictionaryReaderQuotasElement) base [reader_quotas]; }
  118. }
  119. [ConfigurationProperty ("writeEncoding",
  120. Options = ConfigurationPropertyOptions.None,
  121. DefaultValue = "utf-8")]
  122. [TypeConverter ()]
  123. public Encoding WriteEncoding {
  124. get { return (Encoding) base [write_encoding]; }
  125. set { base [write_encoding] = value; }
  126. }
  127. [ConfigurationProperty ("webContentTypeMapperType",
  128. Options = ConfigurationPropertyOptions.None,
  129. DefaultValue = "")]
  130. [StringValidator ( MinLength = 0,
  131. MaxLength = int.MaxValue)]
  132. public string WebContentTypeMapperType {
  133. get { return (string) base [web_content_type_mapper_type]; }
  134. set { base [web_content_type_mapper_type] = value; }
  135. }
  136. [MonoTODO]
  137. protected internal override BindingElement CreateBindingElement ()
  138. {
  139. throw new NotImplementedException ();
  140. }
  141. }
  142. }