Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

305 lines
6.7 KiB

  1. using System;
  2. using System.Collections;
  3. using System.Diagnostics;
  4. using System.Xml.Serialization;
  5. using Microsoft.Uddi;
  6. namespace Microsoft.Uddi.Business
  7. {
  8. /// <summary>
  9. /// The address structure is a simple list of AddressLine elements within the address container.
  10. /// Each addressLine element is a simple string. Uddi compliant registries are responsible for
  11. /// preserving the order of any addressLine data provided. Address structures also have two optional
  12. /// attributes for recording the useType (freeform text) and sortCode data. The sortCode values
  13. /// are not significant within a Uddi registry, but may be used by user interfaces that present
  14. /// address information in some ordered fashion using the values provided in the sortCode attribute.
  15. /// </summary>
  16. public class Address : UddiCore
  17. {
  18. private string sortCode;
  19. private string useType;
  20. private string tModelKey;
  21. private AddressLineCollection addressLines;
  22. /// <summary>
  23. /// Optional attribute that can be used to drive the behavior of external display mechanisms
  24. /// that sort addresses. The suggested values for sortCode include numeric ordering values
  25. /// (e.g. 1, 2, 3), alphabetic character ordering values (e.g. a, b, c) or the first n positions
  26. /// of relevant data within the address.
  27. /// </summary>
  28. [XmlAttribute("sortCode")]
  29. public string SortCode
  30. {
  31. get { return sortCode; }
  32. set { sortCode = value; }
  33. }
  34. /// <summary>
  35. /// Optional attribute that is used to describe the type of address in freeform text.
  36. /// Suggested examples include �headquarters�, �sales office�, �billing department�, etc.
  37. /// </summary>
  38. [XmlAttribute("useType")]
  39. public string UseType
  40. {
  41. get { return useType; }
  42. set { useType = value; }
  43. }
  44. /// <summary>
  45. /// Optional attribute that is used to describe the address using a tModel.
  46. /// </summary>
  47. [XmlAttribute("tModelKey")]
  48. public string TModelKey
  49. {
  50. get { return tModelKey; }
  51. set { tModelKey = value; }
  52. }
  53. /// <summary>
  54. /// AddressLine elements contain string data with a suggested line length limit of
  55. /// 40 character positions. Address line order is significant and will always be
  56. /// returned by the Uddi compliant registry in the order originally provided during
  57. /// a call to save_business.
  58. /// </summary>
  59. [XmlElement("addressLine")]
  60. public AddressLineCollection AddressLines
  61. {
  62. get
  63. {
  64. if( null == addressLines )
  65. {
  66. addressLines = new AddressLineCollection();
  67. }
  68. return addressLines;
  69. }
  70. set { addressLines = value; }
  71. }
  72. public Address() : this( "", "" )
  73. {}
  74. public Address( string sortCode, string useType )
  75. {
  76. SortCode = sortCode;
  77. UseType = useType;
  78. }
  79. public Address( string tModelKey )
  80. {
  81. SortCode = sortCode;
  82. TModelKey = tModelKey;
  83. }
  84. }
  85. public class AddressLine : UddiCore
  86. {
  87. private string keyName;
  88. private string keyValue;
  89. private string text;
  90. public AddressLine() : this( "", null, null )
  91. {}
  92. public AddressLine( string text ) : this( text, null, null )
  93. {}
  94. public AddressLine( string text, string keyName, string keyValue )
  95. {
  96. Text = text;
  97. KeyName = keyName;
  98. KeyValue = keyValue;
  99. }
  100. [ XmlAttribute( "keyName" ) ]
  101. public string KeyName
  102. {
  103. get { return keyName; }
  104. set { keyName = value; }
  105. }
  106. [ XmlAttribute( "keyValue" ) ]
  107. public string KeyValue
  108. {
  109. get { return keyValue; }
  110. set { keyValue = value; }
  111. }
  112. [ XmlText ]
  113. public string Text
  114. {
  115. get { return text; }
  116. set { text = value; }
  117. }
  118. }
  119. public class AddressCollection : CollectionBase
  120. {
  121. public Address this[ int index ]
  122. {
  123. get { return (Address)List[ index ]; }
  124. set { List[ index ] = value; }
  125. }
  126. public int Add( string sortCode, string useType )
  127. {
  128. return List.Add( new Address( sortCode, useType ) );
  129. }
  130. public int Add( string tModelKey )
  131. {
  132. return List.Add( new Address( tModelKey ) );
  133. }
  134. public int Add( Address value )
  135. {
  136. return List.Add( value );
  137. }
  138. public void Insert( int index, Address value )
  139. {
  140. List.Insert( index, value );
  141. }
  142. public int IndexOf( Address value )
  143. {
  144. return List.IndexOf( value );
  145. }
  146. public bool Contains( Address value )
  147. {
  148. return List.Contains( value );
  149. }
  150. public void Remove( Address value )
  151. {
  152. List.Remove( value );
  153. }
  154. public void CopyTo( Address[] array, int index )
  155. {
  156. List.CopyTo( array, index );
  157. }
  158. public new AddressEnumerator GetEnumerator()
  159. {
  160. return new AddressEnumerator( List.GetEnumerator() );
  161. }
  162. }
  163. public sealed class AddressEnumerator : IEnumerator
  164. {
  165. private IEnumerator enumerator;
  166. public AddressEnumerator( IEnumerator enumerator )
  167. {
  168. this.enumerator = enumerator;
  169. }
  170. public Address Current
  171. {
  172. get { return ( Address ) enumerator.Current; }
  173. }
  174. object IEnumerator.Current
  175. {
  176. get{ return enumerator.Current; }
  177. }
  178. public bool MoveNext()
  179. {
  180. return enumerator.MoveNext();
  181. }
  182. public void Reset()
  183. {
  184. enumerator.Reset();
  185. }
  186. }
  187. public class AddressLineCollection : CollectionBase
  188. {
  189. public AddressLine this[ int index ]
  190. {
  191. get { return (AddressLine)List[ index ]; }
  192. set { List[ index ] = value; }
  193. }
  194. public int Add( string text )
  195. {
  196. return List.Add( new AddressLine( text ) );
  197. }
  198. public int Add( string text, string keyName, string keyValue )
  199. {
  200. return List.Add( new AddressLine( text, keyName, keyValue ) );
  201. }
  202. public int Add( AddressLine value )
  203. {
  204. return List.Add( value );
  205. }
  206. public void Insert( int index, AddressLine value )
  207. {
  208. List.Insert( index, value );
  209. }
  210. public int IndexOf( AddressLine value )
  211. {
  212. return List.IndexOf( value );
  213. }
  214. public bool Contains( AddressLine value )
  215. {
  216. return List.Contains( value );
  217. }
  218. public void Remove( AddressLine value )
  219. {
  220. List.Remove( value );
  221. }
  222. public void CopyTo( AddressLine[] array, int index )
  223. {
  224. List.CopyTo( array, index );
  225. }
  226. public new AddressLineEnumerator GetEnumerator()
  227. {
  228. return new AddressLineEnumerator( List.GetEnumerator() );
  229. }
  230. }
  231. public sealed class AddressLineEnumerator : IEnumerator
  232. {
  233. private IEnumerator enumerator;
  234. public AddressLineEnumerator( IEnumerator enumerator )
  235. {
  236. this.enumerator = enumerator;
  237. }
  238. public AddressLine Current
  239. {
  240. get { return ( AddressLine ) enumerator.Current; }
  241. }
  242. object IEnumerator.Current
  243. {
  244. get{ return enumerator.Current; }
  245. }
  246. public bool MoveNext()
  247. {
  248. return enumerator.MoveNext();
  249. }
  250. public void Reset()
  251. {
  252. enumerator.Reset();
  253. }
  254. }
  255. }