The Labs \ Source Viewer \ SSCLI \ System.ComponentModel \ ComponentCollection

  1. //------------------------------------------------------------------------------
  2. // <copyright file="ComponentCollection.cs" company="Microsoft">
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. // </copyright>
  14. // <autogenerated>
  15. // This class was generated by a tool.
  16. // Runtime Version: 1.0.2204.0
  17. //
  18. // Changes to this file may cause incorrect behavior and will be lost if
  19. // the code is regenerated.
  20. // </autogenerated>
  21. //------------------------------------------------------------------------------
  22. using System.Diagnostics.CodeAnalysis;
  23. /*
  24. This class has the HostProtectionAttribute. The purpose of this attribute is to enforce host-specific programming model guidelines, not security behavior.
  25. Suppress FxCop message - BUT REVISIT IF ADDING NEW SECURITY ATTRIBUTES.
  26. */
  27. [assembly: SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member", Target = "System.ComponentModel.ComponentCollection..ctor(System.ComponentModel.IComponent[])")]
  28. [assembly: SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Scope = "member", Target = "System.ComponentModel.ComponentCollection.get_Item(System.String):System.ComponentModel.IComponent")]
  29. namespace System.ComponentModel
  30. {
  31.     using System;
  32.     using System.Collections;
  33.     using System.ComponentModel;
  34.     using System.Globalization;
  35.     using System.Security.Permissions;
  36.    
  37. /** The component in the container identified by name. */   
  38.     /// <devdoc>
  39.     /// <para>
  40.     /// Gets a specific <see cref='System.ComponentModel.Component'/> in the <see cref='System.ComponentModel.Container'/>
  41.     /// .
  42.     /// </para>
  43.     /// </devdoc>
  44.     [System.Runtime.InteropServices.ComVisible(true)]
  45.     [HostProtection(Synchronization = true)]
  46.     public class ComponentCollection : ReadOnlyCollectionBase
  47.     {
  48.         /// <devdoc>
  49.         /// <para>[To be supplied.]</para>
  50.         /// </devdoc>
  51.         public ComponentCollection(IComponent[] components)
  52.         {
  53.             InnerList.AddRange(components);
  54.         }
  55.        
  56. /** The component in the container identified by name. */       
  57.         /// <devdoc>
  58.         /// <para>
  59.         /// Gets a specific <see cref='System.ComponentModel.Component'/> in the <see cref='System.ComponentModel.Container'/>
  60.         /// .
  61.         /// </para>
  62.         /// </devdoc>
  63.         public virtual IComponent this[string name]
  64.         {
  65.             get {
  66.                 if (name != null) {
  67.                     IList list = InnerList;
  68.                     foreach (IComponent comp in list) {
  69.                         if (comp != null && comp.Site != null && comp.Site.Name != null && string.Equals(comp.Site.Name, name, StringComparison.OrdinalIgnoreCase)) {
  70.                             return comp;
  71.                         }
  72.                     }
  73.                 }
  74.                 return null;
  75.             }
  76.         }
  77.        
  78. /** The component in the container identified by index. */       
  79.         /// <devdoc>
  80.         /// <para>
  81.         /// Gets a specific <see cref='System.ComponentModel.Component'/> in the <see cref='System.ComponentModel.Container'/>
  82.         /// .
  83.         /// </para>
  84.         /// </devdoc>
  85.         public virtual IComponent this[int index]
  86.         {
  87.             get { return (IComponent)InnerList[index]; }
  88.         }
  89.        
  90.         /// <devdoc>
  91.         /// <para>[To be supplied.]</para>
  92.         /// </devdoc>
  93.         public void CopyTo(IComponent[] array, int index)
  94.         {
  95.             InnerList.CopyTo(array, index);
  96.         }
  97.     }
  98. }

Developer Fusion