當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。