ServiceCollection.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 { return this [IndexOf ((Service) Table[name])]; }
  29. }
  30. #endregion // Properties
  31. #region Methods
  32. public int Add (Service service)
  33. {
  34. Insert (Count, service);
  35. return (Count - 1);
  36. }
  37. public bool Contains (Service service)
  38. {
  39. return List.Contains (service);
  40. }
  41. public void CopyTo (Service[] array, int index)
  42. {
  43. List.CopyTo (array, index);
  44. }
  45. protected override string GetKey (object value)
  46. {
  47. if (!(value is Service))
  48. throw new InvalidCastException ();
  49. return ((Service) value).Name;
  50. }
  51. public int IndexOf (Service service)
  52. {
  53. return List.IndexOf (service);
  54. }
  55. public void Insert (int index, Service service)
  56. {
  57. List.Insert (index, service);
  58. }
  59. public void Remove (Service service)
  60. {
  61. List.Remove (service);
  62. }
  63. protected override void SetParent (object value, object parent)
  64. {
  65. ((Service) value).SetParent ((ServiceDescription) parent);
  66. }
  67. #endregion // Methods
  68. }
  69. }