CodeAttributeArgumentCollection Class
Represents a collection of CodeAttributeArgument objects.
For a list of all members of this type, see CodeAttributeArgumentCollection Members.
System.Object
System.Collections.CollectionBase
System.CodeDom.CodeAttributeArgumentCollection
[Visual Basic] <Serializable> <ClassInterface(ClassInterfaceType.AutoDispatch)> <ComVisible(True)> Public Class CodeAttributeArgumentCollection Inherits CollectionBase [C#] [Serializable] [ClassInterface(ClassInterfaceType.AutoDispatch)] [ComVisible(true)] public class CodeAttributeArgumentCollection : CollectionBase [C++] [Serializable] [ClassInterface(ClassInterfaceType::AutoDispatch)] [ComVisible(true)] public __gc class CodeAttributeArgumentCollection : public CollectionBase [JScript] public Serializable ClassInterface(ClassInterfaceType.AutoDispatch) ComVisible(true) class CodeAttributeArgumentCollection extends CollectionBase
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Remarks
The CodeAttributeArgumentCollection class provides a simple collection object that can be used to store a set of CodeAttributeArgument objects.
Example
[Visual Basic] ' Creates an empty CodeAttributeArgumentCollection. Dim collection As 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. Dim arguments As CodeAttributeArgument() = {New CodeAttributeArgument(), New CodeAttributeArgument()} collection.AddRange(arguments) ' Adds a collection of CodeAttributeArgument objects to the collection. Dim argumentsCollection As 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 in ' the collection, and retrieves its index if it is found. Dim testArgument As New CodeAttributeArgument("Test Boolean Argument", New CodePrimitiveExpression(True)) Dim itemIndex As Integer = -1 If collection.Contains(testArgument) Then itemIndex = collection.IndexOf(testArgument) End If ' 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. Dim collectionCount As Integer = 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. Dim argument As New CodeAttributeArgument("Test Boolean Argument", New CodePrimitiveExpression(True)) collection.Remove(argument) ' Removes the CodeAttributeArgument at index 0. collection.RemoveAt(0) [C#] // 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); [C++] // Creates an empty CodeAttributeArgumentCollection. CodeAttributeArgumentCollection* collection = new CodeAttributeArgumentCollection(); // Adds a CodeAttributeArgument to the collection. collection->Add( new CodeAttributeArgument(S"Test Boolean Argument", new CodePrimitiveExpression(__box(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(S"TestBooleanArgument", new CodePrimitiveExpression(__box(true))) ); argumentsCollection->Add( new CodeAttributeArgument(S"TestIntArgument", new CodePrimitiveExpression(__box(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(S"Test Boolean Argument", new CodePrimitiveExpression(__box(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(S"Test Boolean Argument", new CodePrimitiveExpression(__box(true))) ); // Removes the specified CodeAttributeArgument from the collection. CodeAttributeArgument* argument = new CodeAttributeArgument(S"Test Boolean Argument", new CodePrimitiveExpression(__box(true))); collection->Remove( argument ); // Removes the CodeAttributeArgument at index 0. collection->RemoveAt(0);
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Namespace: System.CodeDom
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
Assembly: System (in System.dll)
See Also
CodeAttributeArgumentCollection Members | System.CodeDom Namespace | CodeAttributeArgument