ComponentCollection.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //
  2. // System.ComponentModel.ComponentCollection.cs
  3. //
  4. // Author:
  5. // Miguel de Icaza ([email protected])
  6. // Tim Coleman ([email protected])
  7. // Andreas Nahr ([email protected])
  8. //
  9. // (C) Ximian, Inc. http://www.ximian.com
  10. // Copyright (C) Tim Coleman, 2002
  11. // (C) 2003 Andreas Nahr
  12. //
  13. using System.Collections;
  14. using System.Runtime.InteropServices;
  15. using System.Reflection;
  16. namespace System.ComponentModel {
  17. [ComVisible (true)]
  18. public class ComponentCollection : ReadOnlyCollectionBase {
  19. #region Constructors
  20. public ComponentCollection (IComponent[] components)
  21. {
  22. InnerList.AddRange (components);
  23. }
  24. #endregion // Constructors
  25. #region Properties
  26. public virtual IComponent this [int index] {
  27. get { return (IComponent) InnerList[index]; }
  28. }
  29. public virtual IComponent this [string name] {
  30. get {
  31. foreach (IComponent C in InnerList) {
  32. if (C.Site != null)
  33. if (C.Site.Name == name)
  34. return C;
  35. }
  36. return null;
  37. }
  38. }
  39. #endregion // Properties
  40. #region Methods
  41. public void CopyTo (IComponent[] array, int index)
  42. {
  43. InnerList.CopyTo (array,index);
  44. }
  45. #endregion // Methods
  46. }
  47. }