WebScriptEndpointElement.cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. using System;
  27. using System.Collections;
  28. using System.Collections.Generic;
  29. using System.Collections.ObjectModel;
  30. using System.ComponentModel;
  31. using System.Configuration;
  32. using System.Reflection;
  33. using System.ServiceModel;
  34. using System.ServiceModel.Channels;
  35. using System.ServiceModel.Description;
  36. using System.ServiceModel.Diagnostics;
  37. using System.ServiceModel.Dispatcher;
  38. using System.ServiceModel.MsmqIntegration;
  39. using System.ServiceModel.PeerResolvers;
  40. using System.ServiceModel.Security;
  41. using System.ServiceModel.Web;
  42. using System.Runtime.Serialization;
  43. using System.Text;
  44. using System.Xml;
  45. namespace System.ServiceModel.Configuration
  46. {
  47. public class WebScriptEndpointElement : StandardEndpointElement
  48. {
  49. static ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection ();
  50. 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;
  51. static WebScriptEndpointElement ()
  52. {
  53. content_type_mapper = new ConfigurationProperty ("contentTypeMapper", typeof (string), "", null, null, ConfigurationPropertyOptions.None);
  54. cross_domain_script_access_enabled = new ConfigurationProperty ("crossDomainScriptAccessEnabled", typeof (bool), false, null, null, ConfigurationPropertyOptions.None);
  55. host_name_comparison_mode = new ConfigurationProperty ("hostNameComparisonMode", typeof (HostNameComparisonMode), HostNameComparisonMode.StrongWildcard, null, null, ConfigurationPropertyOptions.None);
  56. max_buffer_pool_size = new ConfigurationProperty ("maxBufferPoolSize", typeof (long), 0x80000, null, null, ConfigurationPropertyOptions.None);
  57. max_buffer_size = new ConfigurationProperty ("maxBufferSize", typeof (int), 0x10000, null, null, ConfigurationPropertyOptions.None);
  58. max_received_message_size = new ConfigurationProperty ("maxReceivedMessageSize", typeof (long), 0x10000, null, null, ConfigurationPropertyOptions.None);
  59. reader_quotas = new ConfigurationProperty ("readerQuotas", typeof (XmlDictionaryReaderQuotas), null, null, null, ConfigurationPropertyOptions.None);
  60. security = new ConfigurationProperty ("security", typeof (WebHttpSecurity), null, null, null, ConfigurationPropertyOptions.None);
  61. transfer_mode = new ConfigurationProperty ("transferMode", typeof (TransferMode), TransferMode.Buffered, null, null, ConfigurationPropertyOptions.None);
  62. write_encoding = new ConfigurationProperty ("writeEncoding", typeof (Encoding), "utf-8", new EncodingConverter (), null, ConfigurationPropertyOptions.None);
  63. 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})
  64. properties.Add (item);
  65. }
  66. protected internal override Type EndpointType {
  67. get { return typeof (WebScriptEndpoint); }
  68. }
  69. protected override ConfigurationPropertyCollection Properties {
  70. get { return properties; }
  71. }
  72. [ConfigurationProperty ("contentTypeMapper", DefaultValue = "")]
  73. [StringValidator (MinLength = 0)]
  74. public string ContentTypeMapper {
  75. get { return (string) this ["contentTypeMapper"]; }
  76. set { this ["contentTypeMapper"] = value; }
  77. }
  78. [ConfigurationProperty ("crossDomainScriptAccessEnabled", DefaultValue = false)]
  79. public bool CrossDomainScriptAccessEnabled {
  80. get { return (bool) this ["crossDomainScriptAccessEnabled"]; }
  81. set { this ["crossDomainScriptAccessEnabled"] = value; }
  82. }
  83. [ConfigurationProperty ("hostNameComparisonMode", DefaultValue = HostNameComparisonMode.StrongWildcard)]
  84. public HostNameComparisonMode HostNameComparisonMode {
  85. get { return (HostNameComparisonMode) this ["hostNameComparisonMode"]; }
  86. set { this ["hostNameComparisonMode"] = value; }
  87. }
  88. [LongValidator (MinValue = 0, MaxValue = long.MaxValue, ExcludeRange = false)]
  89. [ConfigurationProperty ("maxBufferPoolSize", DefaultValue = 0x80000,
  90. Options = ConfigurationPropertyOptions.None)]
  91. public long MaxBufferPoolSize {
  92. get { return (long) this ["maxBufferPoolSize"]; }
  93. set { this ["maxBufferPoolSize"] = value; }
  94. }
  95. [IntegerValidator ( MinValue = 1,
  96. MaxValue = int.MaxValue,
  97. ExcludeRange = false)]
  98. [ConfigurationProperty ("maxBufferSize", DefaultValue = 0x10000,
  99. Options = ConfigurationPropertyOptions.None)]
  100. public int MaxBufferSize {
  101. get { return (int) this ["maxBufferSize"]; }
  102. set { this ["maxBufferSize"] = value; }
  103. }
  104. [LongValidator ( MinValue = 1, MaxValue = long.MaxValue, ExcludeRange = false)]
  105. [ConfigurationProperty ("maxReceivedMessageSize", DefaultValue = 0x10000,
  106. Options = ConfigurationPropertyOptions.None)]
  107. public long MaxReceivedMessageSize {
  108. get { return (long) this ["maxReceivedMessageSize"]; }
  109. set { this ["maxReceivedMessageSize"] = value; }
  110. }
  111. [ConfigurationProperty ("readerQuotas")]
  112. public XmlDictionaryReaderQuotasElement ReaderQuotas {
  113. get { return (XmlDictionaryReaderQuotasElement) this ["readerQuotas"]; }
  114. }
  115. [ConfigurationProperty ("security")]
  116. public WebHttpSecurityElement Security {
  117. get { return (WebHttpSecurityElement) this ["security"]; }
  118. }
  119. [ConfigurationProperty ("transferMode", DefaultValue = TransferMode.Buffered)]
  120. public TransferMode TransferMode {
  121. get { return (TransferMode) this ["transferMode"]; }
  122. set { this ["transferMode"] = value; }
  123. }
  124. [TypeConverter (typeof (EncodingConverter))]
  125. [ConfigurationProperty ("writeEncoding", DefaultValue = "utf-8")]
  126. public Encoding WriteEncoding {
  127. get { return (Encoding) this ["writeEncoding"]; }
  128. set { this ["writeEncoding"] = value; }
  129. }
  130. protected internal override ServiceEndpoint CreateServiceEndpoint (ContractDescription contractDescription)
  131. {
  132. throw new NotImplementedException ();
  133. }
  134. protected override void OnApplyConfiguration (ServiceEndpoint endpoint, ChannelEndpointElement serviceEndpointElement)
  135. {
  136. throw new NotImplementedException ();
  137. }
  138. protected override void OnApplyConfiguration (ServiceEndpoint endpoint, ServiceEndpointElement serviceEndpointElement)
  139. {
  140. throw new NotImplementedException ();
  141. }
  142. protected override void OnInitializeAndValidate (ChannelEndpointElement channelEndpointElement)
  143. {
  144. throw new NotImplementedException ();
  145. }
  146. protected override void OnInitializeAndValidate (ServiceEndpointElement serviceEndpointElement)
  147. {
  148. throw new NotImplementedException ();
  149. }
  150. }
  151. }