EventDescriptorCollection.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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;
  19. public static readonly EventDescriptorCollection Empty;
  20. public EventDescriptorCollection (EventDescriptor[] events) {
  21. for (int i = 0; i < events.Length; i++)
  22. this.Add (events[i]);
  23. }
  24. public int Add (EventDescriptor value) {
  25. return eventList.Add (value);
  26. }
  27. public void Clear () {
  28. eventList.Clear ();
  29. }
  30. public bool Contains (EventDescriptor value) {
  31. return eventList.Contains (value);
  32. }
  33. public virtual EventDescriptor Find (string name, bool ignoreCase)
  34. {
  35. foreach (EventDescriptor e in eventList) {
  36. if (0 == String.Compare (name, e.Name, ignoreCase))
  37. return e;
  38. }
  39. return null;
  40. }
  41. public IEnumerator GetEnumerator () {
  42. return eventList.GetEnumerator ();
  43. }
  44. public int IndexOf (EventDescriptor value) {
  45. return eventList.IndexOf (value);
  46. }
  47. public void Insert (int index, EventDescriptor value) {
  48. eventList.Insert (index, value);
  49. }
  50. public void Remove (EventDescriptor value) {
  51. eventList.Remove (value);
  52. }
  53. public void RemoveAt (int index) {
  54. eventList.RemoveAt (index);
  55. }
  56. public virtual EventDescriptorCollection Sort () {
  57. eventList.Sort ();
  58. return this;
  59. }
  60. public virtual EventDescriptorCollection Sort (IComparer comparer) {
  61. eventList.Sort (comparer);
  62. return this;
  63. }
  64. [MonoTODO]
  65. public virtual EventDescriptorCollection Sort (string[] order) {
  66. throw new NotImplementedException ();
  67. }
  68. [MonoTODO]
  69. public virtual EventDescriptorCollection Sort (string[] order, IComparer comparer) {
  70. throw new NotImplementedException ();
  71. }
  72. [MonoTODO]
  73. protected virtual EventDescriptorCollection InternalSort (IComparer comparer) {
  74. throw new NotImplementedException ();
  75. }
  76. [MonoTODO]
  77. protected virtual EventDescriptorCollection 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. [MonoTODO]
  120. set {
  121. throw new NotImplementedException ();
  122. }
  123. }
  124. // ICollection methods
  125. [MonoTODO]
  126. void ICollection.CopyTo (Array array, int index) {
  127. throw new NotImplementedException ();
  128. }
  129. bool ICollection.IsSynchronized {
  130. get { return false; }
  131. }
  132. object ICollection.SyncRoot {
  133. get { return null; }
  134. }
  135. }
  136. }