当前位置: 首页>>代码示例>>C#>>正文


C# AttributeCollection.CopyTo方法代码示例

本文整理汇总了C#中System.ComponentModel.AttributeCollection.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# AttributeCollection.CopyTo方法的具体用法?C# AttributeCollection.CopyTo怎么用?C# AttributeCollection.CopyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.ComponentModel.AttributeCollection的用法示例。


在下文中一共展示了AttributeCollection.CopyTo方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FromExisting

 public static AttributeCollection FromExisting(AttributeCollection existing, params Attribute[] newAttributes)
 {
     if (existing == null)
     {
         throw new ArgumentNullException("existing");
     }
     if (newAttributes == null)
     {
         newAttributes = new Attribute[0];
     }
     Attribute[] array = new Attribute[existing.Count + newAttributes.Length];
     int count = existing.Count;
     existing.CopyTo(array, 0);
     for (int i = 0; i < newAttributes.Length; i++)
     {
         if (newAttributes[i] == null)
         {
             throw new ArgumentNullException("newAttributes");
         }
         bool flag = false;
         for (int j = 0; j < existing.Count; j++)
         {
             if (array[j].TypeId.Equals(newAttributes[i].TypeId))
             {
                 flag = true;
                 array[j] = newAttributes[i];
                 break;
             }
         }
         if (!flag)
         {
             array[count++] = newAttributes[i];
         }
     }
     Attribute[] destinationArray = null;
     if (count < array.Length)
     {
         destinationArray = new Attribute[count];
         Array.Copy(array, 0, destinationArray, 0, count);
     }
     else
     {
         destinationArray = array;
     }
     return new AttributeCollection(destinationArray);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:46,代码来源:AttributeCollection.cs

示例2: AttributeCollectionToArray

 /// <summary>
 /// Creates an Attribute array from an AttributeCollection instance
 /// </summary>
 /// <param name="collection"></param>
 /// <returns></returns>
 private static Attribute[] AttributeCollectionToArray(AttributeCollection collection)
 {
     Attribute[] array = new Attribute[collection.Count];
     collection.CopyTo(array, 0);
     return array;
 }
开发者ID:xenocons,项目名称:visualfsharp,代码行数:11,代码来源:AutomationExtenderManager.cs

示例3: GetAttributesFromCollection

 internal Attribute[] GetAttributesFromCollection(AttributeCollection collection)
 {
     Attribute[] attributes = new Attribute[collection.Count];
     collection.CopyTo(attributes, 0);
     return attributes;
 }
开发者ID:dotnet,项目名称:corefx,代码行数:6,代码来源:DbConnectionStringBuilder.cs

示例4: GetProperties

		private PropertyDescriptorCollection GetProperties (object propertyOwner, AttributeCollection attributes)
		{
			if (propertyOwner == null || property_grid.SelectedTab == null)
				return new PropertyDescriptorCollection (null);

			Attribute[] atts = new Attribute[attributes.Count];
			attributes.CopyTo (atts, 0);
			return property_grid.SelectedTab.GetProperties ((ITypeDescriptorContext)this, propertyOwner, atts);
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:9,代码来源:GridEntry.cs

示例5: FromExisting

        /// <devdoc>
        ///     Creates a new AttributeCollection from an existing AttributeCollection
        /// </devdoc>
        public static AttributeCollection FromExisting(AttributeCollection existing, params Attribute[] newAttributes)
        {
            if (existing == null)
            {
                throw new ArgumentNullException("existing");
            }

            if (newAttributes == null)
            {
                newAttributes = new Attribute[0];
            }

            Attribute[] newArray = new Attribute[existing.Count + newAttributes.Length];
            int actualCount = existing.Count;
            existing.CopyTo(newArray, 0);

            for (int idx = 0; idx < newAttributes.Length; idx++)
            {
                if (newAttributes[idx] == null)
                {
                    throw new ArgumentNullException("newAttributes");
                }

                // We must see if this attribute is already in the existing
                // array.  If it is, we replace it.
                bool match = false;
                for (int existingIdx = 0; existingIdx < existing.Count; existingIdx++)
                {
                    if (newArray[existingIdx].TypeId.Equals(newAttributes[idx].TypeId))
                    {
                        match = true;
                        newArray[existingIdx] = newAttributes[idx];
                        break;
                    }
                }

                if (!match)
                {
                    newArray[actualCount++] = newAttributes[idx];
                }
            }

            // Now, if we collapsed some attributes, create a new array.
            //

            Attribute[] attributes = null;
            if (actualCount < newArray.Length)
            {
                attributes = new Attribute[actualCount];
                Array.Copy(newArray, 0, attributes, 0, actualCount);
            }
            else
            {
                attributes = newArray;
            }

            return new AttributeCollection(attributes);
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:61,代码来源:attributecollection.cs

示例6: GetAttribs

 static Attribute[] GetAttribs(AttributeCollection value)
 {
     if (value == null) return null;
     Attribute[] result = new Attribute[value.Count];
     value.CopyTo(result, 0);
     return result;
 }
开发者ID:usbr,项目名称:Pisces,代码行数:7,代码来源:DataRowEditor.cs

示例7: FromExisting

        /// <summary>
        ///     Creates a new AttributeCollection from an existing AttributeCollection
        /// </summary>
        public static AttributeCollection FromExisting(AttributeCollection existing, params Attribute[] newAttributes)
        {
            // VSWhidbey #75418
            // This method should be a constructor, but making it one introduces a breaking change.
            // 
            if (existing == null)
            {
                throw new ArgumentNullException(nameof(existing));
            }

            if (newAttributes == null)
            {
                newAttributes = Array.Empty<Attribute>();
            }

            Attribute[] newArray = new Attribute[existing.Count + newAttributes.Length];
            int actualCount = existing.Count;
            existing.CopyTo(newArray, 0);

            for (int idx = 0; idx < newAttributes.Length; idx++)
            {
                if (newAttributes[idx] == null)
                {
                    throw new ArgumentNullException(nameof(newAttributes));
                }

                // We must see if this attribute is already in the existing
                // array.  If it is, we replace it.
                bool match = false;
                for (int existingIdx = 0; existingIdx < existing.Count; existingIdx++)
                {
                    if (newArray[existingIdx].TypeId.Equals(newAttributes[idx].TypeId))
                    {
                        match = true;
                        newArray[existingIdx] = newAttributes[idx];
                        break;
                    }
                }

                if (!match)
                {
                    newArray[actualCount++] = newAttributes[idx];
                }
            }

            // Now, if we collapsed some attributes, create a new array.
            //

            Attribute[] attributes = null;
            if (actualCount < newArray.Length)
            {
                attributes = new Attribute[actualCount];
                Array.Copy(newArray, 0, attributes, 0, actualCount);
            }
            else
            {
                attributes = newArray;
            }

            return new AttributeCollection(attributes);
        }
开发者ID:geoffkizer,项目名称:corefx,代码行数:64,代码来源:AttributeCollection.cs

示例8: GetAttributesFromCollection

 private Attribute[] GetAttributesFromCollection(AttributeCollection collection)
 {
     Attribute[] array = new Attribute[collection.Count];
     collection.CopyTo(array, 0);
     return array;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:6,代码来源:OracleConnectionStringBuilder.cs


注:本文中的System.ComponentModel.AttributeCollection.CopyTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。