本文整理汇总了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);
}
示例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;
}
示例3: GetAttributesFromCollection
internal Attribute[] GetAttributesFromCollection(AttributeCollection collection)
{
Attribute[] attributes = new Attribute[collection.Count];
collection.CopyTo(attributes, 0);
return attributes;
}
示例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);
}
示例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);
}
示例6: GetAttribs
static Attribute[] GetAttribs(AttributeCollection value)
{
if (value == null) return null;
Attribute[] result = new Attribute[value.Count];
value.CopyTo(result, 0);
return result;
}
示例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);
}
示例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