WebHttpEndpointElement.cs 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. //
  2. // Author:
  3. // Atsushi Enomoto <[email protected]>
  4. //
  5. // Copyright (C) 2010 Novell, Inc. http://www.novell.com
  6. //
  7. // Permission is hereby granted, free of charge, to any person obtaining
  8. // a copy of this software and associated documentation files (the
  9. // "Software"), to deal in the Software without restriction, including
  10. // without limitation the rights to use, copy, modify, merge, publish,
  11. // distribute, sublicense, and/or sell copies of the Software, and to
  12. // permit persons to whom the Software is furnished to do so, subject to
  13. // the following conditions:
  14. //
  15. // The above copyright notice and this permission notice shall be
  16. // included in all copies or substantial portions of the Software.
  17. //
  18. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  19. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  21. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  22. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  23. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  24. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25. //
  26. #if NET_4_0
  27. using System;
  28. using System.Collections;
  29. using System.Collections.Generic;
  30. using System.Collections.ObjectModel;
  31. using System.ComponentModel;
  32. using System.Configuration;
  33. using System.Reflection;
  34. using System.ServiceModel;
  35. using System.ServiceModel.Channels;
  36. using System.ServiceModel.Description;
  37. using System.ServiceModel.Diagnostics;
  38. using System.ServiceModel.Dispatcher;
  39. using System.ServiceModel.MsmqIntegration;
  40. using System.ServiceModel.PeerResolvers;
  41. using System.ServiceModel.Security;
  42. using System.ServiceModel.Web;
  43. using System.Runtime.Serialization;
  44. using System.Text;
  45. using System.Xml;
  46. namespace System.ServiceModel.Configuration
  47. {
  48. public class WebHttpEndpointElement : StandardEndpointElement
  49. {
  50. static ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection ();
  51. static ConfigurationProperty content_type_mapper, cross_domain_script_access_enabled, host_name_comparison_mode, max_buffer_pool_size, max_buffer_size, max_received_message_size, reader_quotas, security, transfer_mode, write_encoding, automatic_format_selection_enabled, default_outgoing_response_format, fault_exception_enabled, help_enabled;
  52. static WebHttpEndpointElement ()
  53. {
  54. content_type_mapper = new ConfigurationProperty ("contentTypeMapper", typeof (string), "", null, null, ConfigurationPropertyOptions.None);
  55. cross_domain_script_access_enabled = new ConfigurationProperty ("crossDomainScriptAccessEnabled", typeof (bool), false, null, null, ConfigurationPropertyOptions.None);
  56. host_name_comparison_mode = new ConfigurationProperty ("hostNameComparisonMode", typeof (HostNameComparisonMode), HostNameComparisonMode.StrongWildcard, null, null, ConfigurationPropertyOptions.None);
  57. max_buffer_pool_size = new ConfigurationProperty ("maxBufferPoolSize", typeof (long), 0x80000, null, null, ConfigurationPropertyOptions.None);
  58. max_buffer_size = new ConfigurationProperty ("maxBufferSize", typeof (int), 0x10000, null, null, ConfigurationPropertyOptions.None);
  59. max_received_message_size = new ConfigurationProperty ("maxReceivedMessageSize", typeof (long), 0x10000, null, null, ConfigurationPropertyOptions.None);
  60. reader_quotas = new ConfigurationProperty ("readerQuotas", typeof (XmlDictionaryReaderQuotas), null, null, null, ConfigurationPropertyOptions.None);
  61. security = new ConfigurationProperty ("security", typeof (WebHttpSecurity), null, null, null, ConfigurationPropertyOptions.None);
  62. transfer_mode = new ConfigurationProperty ("transferMode", typeof (TransferMode), TransferMode.Buffered, null, null, ConfigurationPropertyOptions.None);
  63. write_encoding = new ConfigurationProperty ("writeEncoding", typeof (Encoding), "utf-8", new EncodingConverter (), null, ConfigurationPropertyOptions.None);
  64. automatic_format_selection_enabled = new ConfigurationProperty ("automaticFormatSelectionEnabled", typeof (bool), false, null, null, ConfigurationPropertyOptions.None);
  65. default_outgoing_response_format = new ConfigurationProperty ("defaultOutgoingResponseFormat", typeof (WebMessageFormat), WebMessageFormat.Xml, null, null, ConfigurationPropertyOptions.None);
  66. fault_exception_enabled = new ConfigurationProperty ("faultExceptionEnabled", typeof (bool), false, null, null, ConfigurationPropertyOptions.None);
  67. help_enabled = new ConfigurationProperty ("helpEnabled", typeof (bool), false, null, null, ConfigurationPropertyOptions.None);
  68. foreach (var item in new ConfigurationProperty [] {content_type_mapper, cross_domain_script_access_enabled, host_name_comparison_mode, max_buffer_pool_size, max_buffer_size, max_received_message_size, reader_quotas, security, transfer_mode, write_encoding, automatic_format_selection_enabled, default_outgoing_response_format, fault_exception_enabled, help_enabled})
  69. properties.Add (item);
  70. }
  71. protected internal override Type EndpointType {
  72. get { return typeof (WebHttpEndpoint); }
  73. }
  74. protected override ConfigurationPropertyCollection Properties {
  75. get { return properties; }
  76. }
  77. [ConfigurationProperty ("contentTypeMapper", DefaultValue = "")]
  78. [StringValidator (MinLength = 0)]
  79. public string ContentTypeMapper {
  80. get { return (string) this ["contentTypeMapper"]; }
  81. set { this ["contentTypeMapper"] = value; }
  82. }
  83. [ConfigurationProperty ("crossDomainScriptAccessEnabled", DefaultValue = false)]
  84. public bool CrossDomainScriptAccessEnabled {
  85. get { return (bool) this ["crossDomainScriptAccessEnabled"]; }
  86. set { this ["crossDomainScriptAccessEnabled"] = value; }
  87. }
  88. [ConfigurationProperty ("hostNameComparisonMode", DefaultValue = HostNameComparisonMode.StrongWildcard)]
  89. public HostNameComparisonMode HostNameComparisonMode {
  90. get { return (HostNameComparisonMode) this ["hostNameComparisonMode"]; }
  91. set { this ["hostNameComparisonMode"] = value; }
  92. }
  93. [LongValidator (MinValue = 0, MaxValue = long.MaxValue, ExcludeRange = false)]
  94. [ConfigurationProperty ("maxBufferPoolSize", DefaultValue = 0x80000,
  95. Options = ConfigurationPropertyOptions.None)]
  96. public long MaxBufferPoolSize {
  97. get { return (long) this ["maxBufferPoolSize"]; }
  98. set { this ["maxBufferPoolSize"] = value; }
  99. }
  100. [IntegerValidator ( MinValue = 1,
  101. MaxValue = int.MaxValue,
  102. ExcludeRange = false)]
  103. [ConfigurationProperty ("maxBufferSize", DefaultValue = 0x10000,
  104. Options = ConfigurationPropertyOptions.None)]
  105. public int MaxBufferSize {
  106. get { return (int) this ["maxBufferSize"]; }
  107. set { this ["maxBufferSize"] = value; }
  108. }
  109. [LongValidator ( MinValue = 1, MaxValue = long.MaxValue, ExcludeRange = false)]
  110. [ConfigurationProperty ("maxReceivedMessageSize", DefaultValue = 0x10000,
  111. Options = ConfigurationPropertyOptions.None)]
  112. public long MaxReceivedMessageSize {
  113. get { return (long) this ["maxReceivedMessageSize"]; }
  114. set { this ["maxReceivedMessageSize"] = value; }
  115. }
  116. [ConfigurationProperty ("readerQuotas")]
  117. public XmlDictionaryReaderQuotasElement ReaderQuotas {
  118. get { return (XmlDictionaryReaderQuotasElement) this ["readerQuotas"]; }
  119. }
  120. [ConfigurationProperty ("security")]
  121. public WebHttpSecurityElement Security {
  122. get { return (WebHttpSecurityElement) this ["security"]; }
  123. }
  124. [ConfigurationProperty ("transferMode", DefaultValue = TransferMode.Buffered)]
  125. public TransferMode TransferMode {
  126. get { return (TransferMode) this ["transferMode"]; }
  127. set { this ["transferMode"] = value; }
  128. }
  129. [TypeConverter (typeof (EncodingConverter))]
  130. [ConfigurationProperty ("writeEncoding", DefaultValue = "utf-8")]
  131. public Encoding WriteEncoding {
  132. get { return (Encoding) this ["writeEncoding"]; }
  133. set { this ["writeEncoding"] = value; }
  134. }
  135. [ConfigurationProperty ("automaticFormatSelectionEnabled", DefaultValue = false)]
  136. public bool AutomaticFormatSelectionEnabled {
  137. get { return (bool) this ["automaticFormatSelectionEnabled"]; }
  138. set { this ["automaticFormatSelectionEnabled"] = value; }
  139. }
  140. [ConfigurationProperty ("defaultOutgoingResponseFormat", DefaultValue = WebMessageFormat.Xml)]
  141. public WebMessageFormat DefaultOutgoingResponseFormat {
  142. get { return (WebMessageFormat) this ["defaultOutgoingResponseFormat"]; }
  143. set { this ["defaultOutgoingResponseFormat"] = value; }
  144. }
  145. [ConfigurationProperty ("faultExceptionEnabled", DefaultValue = false)]
  146. public bool FaultExceptionEnabled {
  147. get { return (bool) this ["faultExceptionEnabled"]; }
  148. set { this ["faultExceptionEnabled"] = value; }
  149. }
  150. [ConfigurationProperty ("helpEnabled", DefaultValue = false)]
  151. public bool HelpEnabled {
  152. get { return (bool) this ["helpEnabled"]; }
  153. set { this ["helpEnabled"] = value; }
  154. }
  155. protected internal override ServiceEndpoint CreateServiceEndpoint (ContractDescription contractDescription)
  156. {
  157. throw new NotImplementedException ();
  158. }
  159. protected override void OnApplyConfiguration (ServiceEndpoint endpoint, ChannelEndpointElement serviceEndpointElement)
  160. {
  161. throw new NotImplementedException ();
  162. }
  163. protected override void OnApplyConfiguration (ServiceEndpoint endpoint, ServiceEndpointElement serviceEndpointElement)
  164. {
  165. throw new NotImplementedException ();
  166. }
  167. protected override void OnInitializeAndValidate (ChannelEndpointElement channelEndpointElement)
  168. {
  169. throw new NotImplementedException ();
  170. }
  171. protected override void OnInitializeAndValidate (ServiceEndpointElement serviceEndpointElement)
  172. {
  173. throw new NotImplementedException ();
  174. }
  175. }
  176. }
  177. #endif