CodeAttributeArgumentCollection Class
.NET Framework 3.0
Represents a collection of CodeAttributeArgument objects.
Namespace: System.CodeDom
Assembly: System (in system.dll)
Assembly: System (in system.dll)
[SerializableAttribute] [ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] [ComVisibleAttribute(true)] public class CodeAttributeArgumentCollection : CollectionBase
/** @attribute SerializableAttribute() */ /** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ /** @attribute ComVisibleAttribute(true) */ public class CodeAttributeArgumentCollection extends CollectionBase
SerializableAttribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) ComVisibleAttribute(true) public class CodeAttributeArgumentCollection extends CollectionBase
Not applicable.
The following example demonstrates the use of the CodeAttributeArgumentCollection class methods. The example creates a new instance of the class and uses the methods to add statements to the collection, return their index, and add or remove attributes at a specific index point.
// Creates an empty CodeAttributeArgumentCollection. CodeAttributeArgumentCollection collection = new CodeAttributeArgumentCollection(); // Adds a CodeAttributeArgument to the collection. collection.Add( new CodeAttributeArgument("Test Boolean Argument", new CodePrimitiveExpression(true)) ); // Adds an array of CodeAttributeArgument objects to the collection. CodeAttributeArgument[] arguments = { new CodeAttributeArgument(), new CodeAttributeArgument() }; collection.AddRange( arguments ); // Adds a collection of CodeAttributeArgument objects to // the collection. CodeAttributeArgumentCollection argumentsCollection = new CodeAttributeArgumentCollection(); argumentsCollection.Add( new CodeAttributeArgument("TestBooleanArgument", new CodePrimitiveExpression(true)) ); argumentsCollection.Add( new CodeAttributeArgument("TestIntArgument", new CodePrimitiveExpression(1)) ); collection.AddRange( argumentsCollection ); // Tests for the presence of a CodeAttributeArgument // within the collection, and retrieves its index if it is found. CodeAttributeArgument testArgument = new CodeAttributeArgument("Test Boolean Argument", new CodePrimitiveExpression(true)); int itemIndex = -1; if( collection.Contains( testArgument ) ) itemIndex = collection.IndexOf( testArgument ); // Copies the contents of the collection beginning at index 0, // to the specified CodeAttributeArgument array. // 'arguments' is a CodeAttributeArgument array. collection.CopyTo( arguments, 0 ); // Retrieves the count of the items in the collection. int collectionCount = collection.Count; // Inserts a CodeAttributeArgument at index 0 of the collection. collection.Insert( 0, new CodeAttributeArgument("Test Boolean Argument", new CodePrimitiveExpression(true)) ); // Removes the specified CodeAttributeArgument from the collection. CodeAttributeArgument argument = new CodeAttributeArgument("Test Boolean Argument", new CodePrimitiveExpression(true)); collection.Remove( argument ); // Removes the CodeAttributeArgument at index 0. collection.RemoveAt(0);
// Creates an empty CodeAttributeArgumentCollection.
CodeAttributeArgumentCollection collection = new
CodeAttributeArgumentCollection();
// Adds a CodeAttributeArgument to the collection.
collection.Add(new CodeAttributeArgument("Test Boolean Argument",
new CodePrimitiveExpression(System.Convert.ToString(true))));
// Adds an array of CodeAttributeArgument objects to the collection.
CodeAttributeArgument arguments[] = {
new CodeAttributeArgument(), new CodeAttributeArgument()
};
collection.AddRange(arguments);
// Adds a collection of CodeAttributeArgument objects to
// the collection.
CodeAttributeArgumentCollection argumentsCollection = new
CodeAttributeArgumentCollection();
argumentsCollection.Add(new CodeAttributeArgument("TestBooleanArgument",
new CodePrimitiveExpression(System.Convert.ToString(true))));
argumentsCollection.Add(new CodeAttributeArgument("TestIntArgument",
new CodePrimitiveExpression(new Integer(1))));
collection.AddRange(argumentsCollection);
// Tests for the presence of a CodeAttributeArgument
// within the collection, and retrieves its index if it is found.
CodeAttributeArgument testArgument = new CodeAttributeArgument("Test "
+ "Boolean Argument",
new CodePrimitiveExpression(System.Convert.ToString(true)));
int itemIndex = -1;
if (collection.Contains(testArgument)) {
itemIndex = collection.IndexOf(testArgument);
}
// Copies the contents of the collection beginning at index 0,
// to the specified CodeAttributeArgument array.
// 'arguments' is a CodeAttributeArgument array.
collection.CopyTo(arguments, 0);
// Retrieves the count of the items in the collection.
int collectionCount = collection.get_Count();
// Inserts a CodeAttributeArgument at index 0 of the collection.
collection.Insert(0, new CodeAttributeArgument("Test Boolean Argument",
new CodePrimitiveExpression(System.Convert.ToString(true))));
// Removes the specified CodeAttributeArgument from the collection.
CodeAttributeArgument argument = new CodeAttributeArgument("Test "
+ "Boolean Argument", new
CodePrimitiveExpression(System.Convert.ToString(true)));
collection.Remove(argument);
// Removes the CodeAttributeArgument at index 0.
collection.RemoveAt(0);
Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.Community Additions
ADD
Show: