EventDescriptorCollection.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. //
  2. // System.ComponentModel.EventDescriptorCollection.cs
  3. //
  4. // Authors:
  5. // Rodrigo Moya ([email protected])
  6. // Andreas Nahr ([email protected])
  7. //
  8. // (C) Ximian, Inc.
  9. // (C) 2003 Andreas Nahr
  10. //
  11. using System.Collections;
  12. using System.Runtime.InteropServices;
  13. namespace System.ComponentModel
  14. {
  15. [ComVisible (true)]
  16. public class EventDescriptorCollection : IList, ICollection, IEnumerable
  17. {
  18. private ArrayList eventList = new ArrayList ();
  19. public static readonly EventDescriptorCollection Empty;
  20. public EventDescriptorCollection (EventDescriptor[] events)
  21. {
  22. for (int i = 0; i < events.Length; i++)
  23. this.Add (events[i]);
  24. }
  25. public int Add (EventDescriptor value) {
  26. return eventList.Add (value);
  27. }
  28. public void Clear () {
  29. eventList.Clear ();
  30. }
  31. public bool Contains (EventDescriptor value) {
  32. return eventList.Contains (value);
  33. }
  34. public virtual EventDescriptor Find (string name, bool ignoreCase)
  35. {
  36. foreach (EventDescriptor e in eventList) {
  37. if (0 == String.Compare (name, e.Name, ignoreCase))
  38. return e;
  39. }
  40. return null;
  41. }
  42. public IEnumerator GetEnumerator () {
  43. return eventList.GetEnumerator ();
  44. }
  45. public int IndexOf (EventDescriptor value) {
  46. return eventList.IndexOf (value);
  47. }
  48. public void Insert (int index, EventDescriptor value) {
  49. eventList.Insert (index, value);
  50. }
  51. public void Remove (EventDescriptor value) {
  52. eventList.Remove (value);
  53. }
  54. public void RemoveAt (int index) {
  55. eventList.RemoveAt (index);
  56. }
  57. public virtual EventDescriptorCollection Sort () {
  58. eventList.Sort ();
  59. return this;
  60. }
  61. public virtual EventDescriptorCollection Sort (IComparer comparer) {
  62. eventList.Sort (comparer);
  63. return this;
  64. }
  65. [MonoTODO]
  66. public virtual EventDescriptorCollection Sort (string[] order) {
  67. throw new NotImplementedException ();
  68. }
  69. [MonoTODO]
  70. public virtual EventDescriptorCollection Sort (string[] order, IComparer comparer) {
  71. throw new NotImplementedException ();
  72. }
  73. protected void InternalSort (IComparer comparer) {
  74. eventList.Sort (comparer);
  75. }
  76. [MonoTODO]
  77. protected void InternalSort (string[] order) {
  78. throw new NotImplementedException ();
  79. }
  80. public int Count {
  81. get {
  82. return eventList.Count;
  83. }
  84. }
  85. public virtual EventDescriptor this[string name] {
  86. get { return Find (name, false); }
  87. }
  88. public virtual EventDescriptor this[int index] {
  89. get {
  90. return (EventDescriptor) eventList[index];
  91. }
  92. }
  93. // IList methods
  94. int IList.Add (object value) {
  95. return Add ((EventDescriptor) value);
  96. }
  97. bool IList.Contains (object value) {
  98. return Contains ((EventDescriptor) value);
  99. }
  100. int IList.IndexOf (object value) {
  101. return IndexOf ((EventDescriptor) value);
  102. }
  103. void IList.Insert (int index, object value) {
  104. Insert (index, (EventDescriptor) value);
  105. }
  106. void IList.Remove (object value) {
  107. Remove ((EventDescriptor) value);
  108. }
  109. bool IList.IsFixedSize {
  110. get { return false; }
  111. }
  112. bool IList.IsReadOnly {
  113. get { return false; }
  114. }
  115. object IList.this[int index] {
  116. get {
  117. return eventList[index];
  118. }
  119. set {
  120. eventList[index] = value;
  121. }
  122. }
  123. // ICollection methods
  124. void ICollection.CopyTo (Array array, int index) {
  125. eventList.CopyTo (array, index);
  126. }
  127. bool ICollection.IsSynchronized {
  128. get { return false; }
  129. }
  130. object ICollection.SyncRoot {
  131. get { return null; }
  132. }
  133. }
  134. }