ServiceCollection.cs 1.8 KB

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