ServiceCollection.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 Fields
  13. ServiceDescription serviceDescription;
  14. #endregion // Fields
  15. #region Constructors
  16. internal ServiceCollection (ServiceDescription serviceDescription)
  17. {
  18. this.serviceDescription = serviceDescription;
  19. }
  20. #endregion // Constructors
  21. #region Properties
  22. public Service this [int index] {
  23. get {
  24. if (index < 0 || index > Count)
  25. throw new ArgumentOutOfRangeException ();
  26. return (Service) List[index];
  27. }
  28. [MonoTODO]
  29. set { throw new NotImplementedException (); }
  30. }
  31. public Service this [string name] {
  32. get { return this[IndexOf ((Service) Table[name])]; }
  33. }
  34. #endregion // Properties
  35. #region Methods
  36. public int Add (Service service)
  37. {
  38. Insert (Count, service);
  39. return (Count - 1);
  40. }
  41. public bool Contains (Service service)
  42. {
  43. return List.Contains (service);
  44. }
  45. public void CopyTo (Service[] array, int index)
  46. {
  47. List.CopyTo (array, index);
  48. }
  49. protected override string GetKey (object value)
  50. {
  51. if (!(value is Service))
  52. throw new InvalidCastException ();
  53. return ((Service) value).Name;
  54. }
  55. public int IndexOf (Service service)
  56. {
  57. return List.IndexOf (service);
  58. }
  59. public void Insert (int index, Service service)
  60. {
  61. SetParent (service, serviceDescription);
  62. Table [GetKey (service)] = service;
  63. List.Insert (index, service);
  64. }
  65. public void Remove (Service service)
  66. {
  67. Table.Remove (GetKey (service));
  68. List.Remove (service);
  69. }
  70. protected override void SetParent (object value, object parent)
  71. {
  72. ((Service) value).SetParent ((ServiceDescription) parent);
  73. }
  74. #endregion // Methods
  75. }
  76. }