WebHttpBindingElement.cs 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. //
  2. // WebHttpBindingElement.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 partial class WebHttpBindingElement
  49. : StandardBindingElement, IBindingConfigurationElement
  50. {
  51. // Static Fields
  52. static ConfigurationPropertyCollection properties;
  53. static ConfigurationProperty allow_cookies;
  54. static ConfigurationProperty binding_element_type;
  55. static ConfigurationProperty bypass_proxy_on_local;
  56. static ConfigurationProperty host_name_comparison_mode;
  57. static ConfigurationProperty max_buffer_pool_size;
  58. static ConfigurationProperty max_buffer_size;
  59. static ConfigurationProperty max_received_message_size;
  60. static ConfigurationProperty proxy_address;
  61. static ConfigurationProperty reader_quotas;
  62. static ConfigurationProperty security;
  63. static ConfigurationProperty write_encoding;
  64. static ConfigurationProperty transfer_mode;
  65. static ConfigurationProperty use_default_web_proxy;
  66. static WebHttpBindingElement ()
  67. {
  68. properties = new ConfigurationPropertyCollection ();
  69. allow_cookies = new ConfigurationProperty ("allowCookies",
  70. typeof (bool), "false", new BooleanConverter (), null,
  71. ConfigurationPropertyOptions.None);
  72. binding_element_type = new ConfigurationProperty ("",
  73. typeof (Type), null, new TypeConverter (), null,
  74. ConfigurationPropertyOptions.None);
  75. bypass_proxy_on_local = new ConfigurationProperty ("bypassProxyOnLocal",
  76. typeof (bool), "false", new BooleanConverter (), null,
  77. ConfigurationPropertyOptions.None);
  78. host_name_comparison_mode = new ConfigurationProperty ("hostNameComparisonMode",
  79. typeof (HostNameComparisonMode), "StrongWildcard", null/* FIXME: get converter for HostNameComparisonMode*/, null,
  80. ConfigurationPropertyOptions.None);
  81. max_buffer_pool_size = new ConfigurationProperty ("maxBufferPoolSize",
  82. typeof (long), "524288", null/* FIXME: get converter for long*/, null,
  83. ConfigurationPropertyOptions.None);
  84. max_buffer_size = new ConfigurationProperty ("maxBufferSize",
  85. typeof (int), "65536", null/* FIXME: get converter for int*/, null,
  86. ConfigurationPropertyOptions.None);
  87. max_received_message_size = new ConfigurationProperty ("maxReceivedMessageSize",
  88. typeof (long), "65536", null/* FIXME: get converter for long*/, null,
  89. ConfigurationPropertyOptions.None);
  90. proxy_address = new ConfigurationProperty ("proxyAddress",
  91. typeof (Uri), null, new UriTypeConverter (), null,
  92. ConfigurationPropertyOptions.None);
  93. reader_quotas = new ConfigurationProperty ("readerQuotas",
  94. typeof (XmlDictionaryReaderQuotasElement), null, null/* FIXME: get converter for XmlDictionaryReaderQuotasElement*/, null,
  95. ConfigurationPropertyOptions.None);
  96. security = new ConfigurationProperty ("security",
  97. typeof (WebHttpSecurityElement), null, null/* FIXME: get converter for WebHttpSecurityElement*/, null,
  98. ConfigurationPropertyOptions.None);
  99. write_encoding = new ConfigurationProperty ("writeEncoding",
  100. typeof (Encoding), "utf-8", null/* FIXME: get converter for Encoding*/, null,
  101. ConfigurationPropertyOptions.None);
  102. transfer_mode = new ConfigurationProperty ("transferMode",
  103. typeof (TransferMode), "Buffered", null/* FIXME: get converter for TransferMode*/, null,
  104. ConfigurationPropertyOptions.None);
  105. use_default_web_proxy = new ConfigurationProperty ("useDefaultWebProxy",
  106. typeof (bool), "true", new BooleanConverter (), null,
  107. ConfigurationPropertyOptions.None);
  108. properties.Add (allow_cookies);
  109. properties.Add (binding_element_type);
  110. properties.Add (bypass_proxy_on_local);
  111. properties.Add (host_name_comparison_mode);
  112. properties.Add (max_buffer_pool_size);
  113. properties.Add (max_buffer_size);
  114. properties.Add (max_received_message_size);
  115. properties.Add (proxy_address);
  116. properties.Add (reader_quotas);
  117. properties.Add (security);
  118. properties.Add (write_encoding);
  119. properties.Add (transfer_mode);
  120. properties.Add (use_default_web_proxy);
  121. }
  122. public WebHttpBindingElement ()
  123. {
  124. }
  125. // Properties
  126. [ConfigurationProperty ("allowCookies",
  127. DefaultValue = false,
  128. Options = ConfigurationPropertyOptions.None)]
  129. public bool AllowCookies {
  130. get { return (bool) base [allow_cookies]; }
  131. set { base [allow_cookies] = value; }
  132. }
  133. protected override Type BindingElementType {
  134. get { return (Type) base [binding_element_type]; }
  135. }
  136. [ConfigurationProperty ("bypassProxyOnLocal",
  137. DefaultValue = false,
  138. Options = ConfigurationPropertyOptions.None)]
  139. public bool BypassProxyOnLocal {
  140. get { return (bool) base [bypass_proxy_on_local]; }
  141. set { base [bypass_proxy_on_local] = value; }
  142. }
  143. [ConfigurationProperty ("hostNameComparisonMode",
  144. DefaultValue = "StrongWildcard",
  145. Options = ConfigurationPropertyOptions.None)]
  146. public HostNameComparisonMode HostNameComparisonMode {
  147. get { return (HostNameComparisonMode) base [host_name_comparison_mode]; }
  148. set { base [host_name_comparison_mode] = value; }
  149. }
  150. [LongValidator ( MinValue = 0,
  151. MaxValue = 9223372036854775807,
  152. ExcludeRange = false)]
  153. [ConfigurationProperty ("maxBufferPoolSize",
  154. DefaultValue = "524288",
  155. Options = ConfigurationPropertyOptions.None)]
  156. public long MaxBufferPoolSize {
  157. get { return (long) base [max_buffer_pool_size]; }
  158. set { base [max_buffer_pool_size] = value; }
  159. }
  160. [IntegerValidator ( MinValue = 1,
  161. MaxValue = int.MaxValue,
  162. ExcludeRange = false)]
  163. [ConfigurationProperty ("maxBufferSize",
  164. DefaultValue = "65536",
  165. Options = ConfigurationPropertyOptions.None)]
  166. public int MaxBufferSize {
  167. get { return (int) base [max_buffer_size]; }
  168. set { base [max_buffer_size] = value; }
  169. }
  170. [LongValidator ( MinValue = 1,
  171. MaxValue = 9223372036854775807,
  172. ExcludeRange = false)]
  173. [ConfigurationProperty ("maxReceivedMessageSize",
  174. DefaultValue = "65536",
  175. Options = ConfigurationPropertyOptions.None)]
  176. public long MaxReceivedMessageSize {
  177. get { return (long) base [max_received_message_size]; }
  178. set { base [max_received_message_size] = value; }
  179. }
  180. protected override ConfigurationPropertyCollection Properties {
  181. get { return properties; }
  182. }
  183. [ConfigurationProperty ("proxyAddress",
  184. DefaultValue = null,
  185. Options = ConfigurationPropertyOptions.None)]
  186. public Uri ProxyAddress {
  187. get { return (Uri) base [proxy_address]; }
  188. set { base [proxy_address] = value; }
  189. }
  190. [ConfigurationProperty ("readerQuotas",
  191. Options = ConfigurationPropertyOptions.None)]
  192. public XmlDictionaryReaderQuotasElement ReaderQuotas {
  193. get { return (XmlDictionaryReaderQuotasElement) base [reader_quotas]; }
  194. }
  195. [ConfigurationProperty ("security",
  196. Options = ConfigurationPropertyOptions.None)]
  197. public WebHttpSecurityElement Security {
  198. get { return (WebHttpSecurityElement) base [security]; }
  199. }
  200. [TypeConverter ()]
  201. [ConfigurationProperty ("writeEncoding",
  202. DefaultValue = "utf-8",
  203. Options = ConfigurationPropertyOptions.None)]
  204. public Encoding WriteEncoding {
  205. get { return (Encoding) base [write_encoding]; }
  206. set { base [write_encoding] = value; }
  207. }
  208. [ConfigurationProperty ("transferMode",
  209. DefaultValue = "Buffered",
  210. Options = ConfigurationPropertyOptions.None)]
  211. public TransferMode TransferMode {
  212. get { return (TransferMode) base [transfer_mode]; }
  213. set { base [transfer_mode] = value; }
  214. }
  215. [ConfigurationProperty ("useDefaultWebProxy",
  216. DefaultValue = true,
  217. Options = ConfigurationPropertyOptions.None)]
  218. public bool UseDefaultWebProxy {
  219. get { return (bool) base [use_default_web_proxy]; }
  220. set { base [use_default_web_proxy] = value; }
  221. }
  222. protected override void OnApplyConfiguration (Binding binding)
  223. {
  224. throw new NotImplementedException ();
  225. }
  226. }
  227. }