PortCollection.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. //
  2. // System.Web.Services.Description.PortCollection.cs
  3. //
  4. // Author:
  5. // Tim Coleman ([email protected])
  6. //
  7. // Copyright (C) Tim Coleman, 2002
  8. //
  9. namespace System.Web.Services.Description {
  10. public sealed class PortCollection : ServiceDescriptionBaseCollection {
  11. #region Constructors
  12. internal PortCollection (Service service)
  13. : base (service)
  14. {
  15. }
  16. #endregion
  17. #region Properties
  18. public Port this [int index] {
  19. get {
  20. if (index < 0 || index > Count)
  21. throw new ArgumentOutOfRangeException ();
  22. return (Port) List[index];
  23. }
  24. set { List [index] = value; }
  25. }
  26. public Port this [string name] {
  27. get {
  28. int index = IndexOf ((Port) Table[name]);
  29. if (index >= 0)
  30. return this[index];
  31. return null;
  32. }
  33. }
  34. #endregion // Properties
  35. #region Methods
  36. public int Add (Port port)
  37. {
  38. Insert (Count, port);
  39. return (Count - 1);
  40. }
  41. public bool Contains (Port port)
  42. {
  43. return List.Contains (port);
  44. }
  45. public void CopyTo (Port[] array, int index)
  46. {
  47. List.CopyTo (array, index);
  48. }
  49. protected override string GetKey (object value)
  50. {
  51. if (!(value is Port))
  52. throw new InvalidCastException ();
  53. return ((Port) value).Name;
  54. }
  55. public int IndexOf (Port port)
  56. {
  57. return List.IndexOf (port);
  58. }
  59. public void Insert (int index, Port port)
  60. {
  61. List.Insert (index, port);
  62. }
  63. public void Remove (Port port)
  64. {
  65. List.Remove (port);
  66. }
  67. protected override void SetParent (object value, object parent)
  68. {
  69. ((Port) value).SetParent ((Service) parent);
  70. }
  71. #endregion // Methods
  72. }
  73. }