ServiceEndpointElement.cs 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. //
  2. // ServiceEndpointElement.cs
  3. //
  4. // Author:
  5. // Atsushi Enomoto <[email protected]>
  6. //
  7. // Copyright (C) 2006 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.Security.Cryptography.X509Certificates;
  38. using System.Security.Principal;
  39. using System.IdentityModel.Claims;
  40. using System.IdentityModel.Policy;
  41. using System.IdentityModel.Tokens;
  42. using System.ServiceModel;
  43. using System.ServiceModel.Channels;
  44. using System.ServiceModel.Description;
  45. using System.ServiceModel.Diagnostics;
  46. using System.ServiceModel.Dispatcher;
  47. using System.ServiceModel.MsmqIntegration;
  48. using System.ServiceModel.PeerResolvers;
  49. using System.ServiceModel.Security;
  50. using System.Runtime.Serialization;
  51. using System.Text;
  52. using System.Xml;
  53. namespace System.ServiceModel.Configuration
  54. {
  55. public sealed class ServiceEndpointElement
  56. : ConfigurationElement
  57. {
  58. // Static Fields
  59. static ConfigurationPropertyCollection properties;
  60. static ConfigurationProperty address;
  61. static ConfigurationProperty behavior_configuration;
  62. static ConfigurationProperty binding;
  63. static ConfigurationProperty binding_configuration;
  64. static ConfigurationProperty binding_name;
  65. static ConfigurationProperty binding_namespace;
  66. static ConfigurationProperty contract;
  67. static ConfigurationProperty headers;
  68. static ConfigurationProperty identity;
  69. static ConfigurationProperty listen_uri;
  70. static ConfigurationProperty listen_uri_mode;
  71. static ConfigurationProperty name;
  72. static ServiceEndpointElement ()
  73. {
  74. properties = new ConfigurationPropertyCollection ();
  75. address = new ConfigurationProperty ("address",
  76. typeof (Uri), "", new UriTypeConverter (), null,
  77. ConfigurationPropertyOptions.IsKey);
  78. behavior_configuration = new ConfigurationProperty ("behaviorConfiguration",
  79. typeof (string), "", new StringConverter (), new StringValidator (0, int.MaxValue, null),
  80. ConfigurationPropertyOptions.None);
  81. binding = new ConfigurationProperty ("binding",
  82. typeof (string), null, new StringConverter (), new StringValidator (1, int.MaxValue, null),
  83. ConfigurationPropertyOptions.IsRequired| ConfigurationPropertyOptions.IsKey);
  84. binding_configuration = new ConfigurationProperty ("bindingConfiguration",
  85. typeof (string), "", new StringConverter (), new StringValidator (0, int.MaxValue, null),
  86. ConfigurationPropertyOptions.IsKey);
  87. binding_name = new ConfigurationProperty ("bindingName",
  88. typeof (string), "", new StringConverter (), new StringValidator (0, int.MaxValue, null),
  89. ConfigurationPropertyOptions.IsKey);
  90. binding_namespace = new ConfigurationProperty ("bindingNamespace",
  91. typeof (string), "", new StringConverter (), new StringValidator (0, int.MaxValue, null),
  92. ConfigurationPropertyOptions.IsKey);
  93. contract = new ConfigurationProperty ("contract",
  94. typeof (string), "", new StringConverter (), new StringValidator (0, int.MaxValue, null),
  95. ConfigurationPropertyOptions.IsKey);
  96. headers = new ConfigurationProperty ("headers",
  97. typeof (AddressHeaderCollectionElement), null, null, null,
  98. ConfigurationPropertyOptions.None);
  99. identity = new ConfigurationProperty ("identity",
  100. typeof (IdentityElement), null, null, null,
  101. ConfigurationPropertyOptions.None);
  102. listen_uri = new ConfigurationProperty ("listenUri",
  103. typeof (Uri), null, new UriTypeConverter (), null,
  104. ConfigurationPropertyOptions.None);
  105. listen_uri_mode = new ConfigurationProperty ("listenUriMode",
  106. typeof (ListenUriMode), "Explicit", null, null,
  107. ConfigurationPropertyOptions.None);
  108. name = new ConfigurationProperty ("name",
  109. typeof (string), "", new StringConverter (), new StringValidator (0, int.MaxValue, null),
  110. ConfigurationPropertyOptions.None);
  111. properties.Add (address);
  112. properties.Add (behavior_configuration);
  113. properties.Add (binding);
  114. properties.Add (binding_configuration);
  115. properties.Add (binding_name);
  116. properties.Add (binding_namespace);
  117. properties.Add (contract);
  118. properties.Add (headers);
  119. properties.Add (identity);
  120. properties.Add (listen_uri);
  121. properties.Add (listen_uri_mode);
  122. properties.Add (name);
  123. }
  124. public ServiceEndpointElement ()
  125. {
  126. }
  127. // Properties
  128. [ConfigurationProperty ("address",
  129. Options = ConfigurationPropertyOptions.IsKey,
  130. DefaultValue = "",
  131. IsKey = true)]
  132. public Uri Address {
  133. get { return (Uri) base [address]; }
  134. set { base [address] = value; }
  135. }
  136. [StringValidator ( MinLength = 0,
  137. MaxLength = int.MaxValue,
  138. InvalidCharacters = null)]
  139. [ConfigurationProperty ("behaviorConfiguration",
  140. Options = ConfigurationPropertyOptions.None,
  141. DefaultValue = "")]
  142. public string BehaviorConfiguration {
  143. get { return (string) base [behavior_configuration]; }
  144. set { base [behavior_configuration] = value; }
  145. }
  146. [StringValidator ( MinLength = 1,
  147. MaxLength = int.MaxValue,
  148. InvalidCharacters = null)]
  149. [ConfigurationProperty ("binding",
  150. Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey,
  151. IsRequired = true,
  152. IsKey = true)]
  153. public string Binding {
  154. get { return (string) base [binding]; }
  155. set { base [binding] = value; }
  156. }
  157. [ConfigurationProperty ("bindingConfiguration",
  158. Options = ConfigurationPropertyOptions.IsKey,
  159. DefaultValue = "",
  160. IsKey = true)]
  161. [StringValidator ( MinLength = 0,
  162. MaxLength = int.MaxValue,
  163. InvalidCharacters = null)]
  164. public string BindingConfiguration {
  165. get { return (string) base [binding_configuration]; }
  166. set { base [binding_configuration] = value; }
  167. }
  168. [ConfigurationProperty ("bindingName",
  169. Options = ConfigurationPropertyOptions.IsKey,
  170. DefaultValue = "",
  171. IsKey = true)]
  172. [StringValidator ( MinLength = 0,
  173. MaxLength = int.MaxValue,
  174. InvalidCharacters = null)]
  175. public string BindingName {
  176. get { return (string) base [binding_name]; }
  177. set { base [binding_name] = value; }
  178. }
  179. [ConfigurationProperty ("bindingNamespace",
  180. Options = ConfigurationPropertyOptions.IsKey,
  181. DefaultValue = "",
  182. IsKey = true)]
  183. [StringValidator ( MinLength = 0,
  184. MaxLength = int.MaxValue,
  185. InvalidCharacters = null)]
  186. public string BindingNamespace {
  187. get { return (string) base [binding_namespace]; }
  188. set { base [binding_namespace] = value; }
  189. }
  190. [StringValidator ( MinLength = 0,
  191. MaxLength = int.MaxValue,
  192. InvalidCharacters = null)]
  193. [ConfigurationProperty ("contract",
  194. Options = ConfigurationPropertyOptions.IsKey,
  195. DefaultValue = "",
  196. IsKey = true)]
  197. public string Contract {
  198. get { return (string) base [contract]; }
  199. set { base [contract] = value; }
  200. }
  201. [ConfigurationProperty ("headers",
  202. Options = ConfigurationPropertyOptions.None)]
  203. public AddressHeaderCollectionElement Headers {
  204. get { return (AddressHeaderCollectionElement) base [headers]; }
  205. }
  206. [ConfigurationProperty ("identity",
  207. Options = ConfigurationPropertyOptions.None)]
  208. public IdentityElement Identity {
  209. get { return (IdentityElement) base [identity]; }
  210. }
  211. [ConfigurationProperty ("listenUri",
  212. Options = ConfigurationPropertyOptions.None,
  213. DefaultValue = null)]
  214. public Uri ListenUri {
  215. get { return (Uri) base [listen_uri]; }
  216. set { base [listen_uri] = value; }
  217. }
  218. [ConfigurationProperty ("listenUriMode",
  219. Options = ConfigurationPropertyOptions.None,
  220. DefaultValue = "Explicit")]
  221. public ListenUriMode ListenUriMode {
  222. get { return (ListenUriMode) base [listen_uri_mode]; }
  223. set { base [listen_uri_mode] = value; }
  224. }
  225. [StringValidator ( MinLength = 0,
  226. MaxLength = int.MaxValue,
  227. InvalidCharacters = null)]
  228. [ConfigurationProperty ("name",
  229. Options = ConfigurationPropertyOptions.None,
  230. DefaultValue = "")]
  231. public string Name {
  232. get { return (string) base [name]; }
  233. set { base [name] = value; }
  234. }
  235. protected override ConfigurationPropertyCollection Properties {
  236. get { return properties; }
  237. }
  238. }
  239. }