BindingCollection.cs 2.0 KB

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