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.

190 lines
3.3 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. public class Contact : UddiCore
  9. {
  10. private string useType;
  11. private string personName;
  12. private DescriptionCollection descriptions;
  13. private PhoneCollection phones;
  14. private EmailCollection emails;
  15. private AddressCollection addresses;
  16. public Contact() : this( "", "" )
  17. {}
  18. public Contact( string personName, string useType )
  19. {
  20. PersonName = personName;
  21. UseType = useType;
  22. }
  23. [XmlAttribute("useType")]
  24. public string UseType
  25. {
  26. get { return useType; }
  27. set { useType = value; }
  28. }
  29. [XmlElement("description")]
  30. public DescriptionCollection Descriptions
  31. {
  32. get
  33. {
  34. if( null == descriptions )
  35. {
  36. descriptions = new DescriptionCollection();
  37. }
  38. return descriptions;
  39. }
  40. set { descriptions = value; }
  41. }
  42. [XmlElement("personName")]
  43. public string PersonName
  44. {
  45. get { return personName; }
  46. set { personName = value; }
  47. }
  48. [XmlElement("phone")]
  49. public PhoneCollection Phones
  50. {
  51. get
  52. {
  53. if( null == phones )
  54. {
  55. phones = new PhoneCollection();
  56. }
  57. return phones;
  58. }
  59. set { phones = value; }
  60. }
  61. [XmlElement("email")]
  62. public EmailCollection Emails
  63. {
  64. get
  65. {
  66. if( null == emails )
  67. {
  68. emails = new EmailCollection();
  69. }
  70. return emails;
  71. }
  72. set { emails = value; }
  73. }
  74. [XmlElement("address")]
  75. public AddressCollection Addresses
  76. {
  77. get
  78. {
  79. if( null == addresses )
  80. {
  81. addresses = new AddressCollection();
  82. }
  83. return addresses;
  84. }
  85. set { addresses = value; }
  86. }
  87. }
  88. public class ContactCollection : CollectionBase
  89. {
  90. public Contact this[ int index ]
  91. {
  92. get { return ( Contact)List[index]; }
  93. set { List[ index ] = value; }
  94. }
  95. public int Add( string personName )
  96. {
  97. return List.Add( new Contact( personName, null ) );
  98. }
  99. public int Add( string personName, string useType )
  100. {
  101. return List.Add( new Contact( personName, useType ) );
  102. }
  103. public int Add( Contact value )
  104. {
  105. return List.Add( value );
  106. }
  107. public void Insert( int index, Contact value )
  108. {
  109. List.Insert( index, value );
  110. }
  111. public int IndexOf( Contact value )
  112. {
  113. return List.IndexOf( value );
  114. }
  115. public bool Contains( Contact value )
  116. {
  117. return List.Contains( value );
  118. }
  119. public void Remove( Contact value )
  120. {
  121. List.Remove( value );
  122. }
  123. public void CopyTo( Contact[] array, int index )
  124. {
  125. List.CopyTo( array, index );
  126. }
  127. public new ContactEnumerator GetEnumerator()
  128. {
  129. return new ContactEnumerator( List.GetEnumerator() );
  130. }
  131. }
  132. public sealed class ContactEnumerator : IEnumerator
  133. {
  134. private IEnumerator enumerator;
  135. public ContactEnumerator( IEnumerator enumerator )
  136. {
  137. this.enumerator = enumerator;
  138. }
  139. public Contact Current
  140. {
  141. get { return ( Contact ) enumerator.Current; }
  142. }
  143. object IEnumerator.Current
  144. {
  145. get{ return enumerator.Current; }
  146. }
  147. public bool MoveNext()
  148. {
  149. return enumerator.MoveNext();
  150. }
  151. public void Reset()
  152. {
  153. enumerator.Reset();
  154. }
  155. }
  156. }