次の方法で共有


CodeAttributeDeclarationCollection クラス

CodeAttributeDeclaration オブジェクトのコレクションを表します。

名前空間: System.CodeDom
アセンブリ: System (system.dll 内)

構文

'宣言
<SerializableAttribute> _
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<ComVisibleAttribute(True)> _
Public Class CodeAttributeDeclarationCollection
    Inherits CollectionBase
'使用
Dim instance As CodeAttributeDeclarationCollection
[SerializableAttribute] 
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] 
[ComVisibleAttribute(true)] 
public class CodeAttributeDeclarationCollection : CollectionBase
[SerializableAttribute] 
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] 
[ComVisibleAttribute(true)] 
public ref class CodeAttributeDeclarationCollection : public CollectionBase
/** @attribute SerializableAttribute() */ 
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ 
/** @attribute ComVisibleAttribute(true) */ 
public class CodeAttributeDeclarationCollection extends CollectionBase
SerializableAttribute 
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) 
ComVisibleAttribute(true) 
public class CodeAttributeDeclarationCollection extends CollectionBase

解説

CodeAttributeDeclarationCollection クラスは、CodeAttributeDeclaration オブジェクトのセットを格納するために使用できる単純なコレクション オブジェクトを提供します。

使用例

' Creates an empty CodeAttributeDeclarationCollection.
Dim collection As New CodeAttributeDeclarationCollection()

' Adds a CodeAttributeDeclaration to the collection.
collection.Add(New CodeAttributeDeclaration("DescriptionAttribute", New CodeAttributeArgument(New CodePrimitiveExpression("Test Description"))))

' Adds an array of CodeAttributeDeclaration objects to the collection.
Dim declarations As CodeAttributeDeclaration() = {New CodeAttributeDeclaration(), New CodeAttributeDeclaration()}
collection.AddRange(declarations)

' Adds a collection of CodeAttributeDeclaration objects to 
' the collection.
Dim declarationsCollection As New CodeAttributeDeclarationCollection()
declarationsCollection.Add(New CodeAttributeDeclaration("DescriptionAttribute", New CodeAttributeArgument(New CodePrimitiveExpression("Test Description"))))
declarationsCollection.Add(New CodeAttributeDeclaration("BrowsableAttribute", New CodeAttributeArgument(New CodePrimitiveExpression(True))))
collection.AddRange(declarationsCollection)

' Tests for the presence of a CodeAttributeDeclaration in the 
' collection, and retrieves its index if it is found.
Dim testdeclaration As New CodeAttributeDeclaration("DescriptionAttribute", New CodeAttributeArgument(New CodePrimitiveExpression("Test Description")))
Dim itemIndex As Integer = -1
If collection.Contains(testdeclaration) Then
    itemIndex = collection.IndexOf(testdeclaration)
End If

' Copies the contents of the collection beginning at index 0 to the specified CodeAttributeDeclaration array.
' 'declarations' is a CodeAttributeDeclaration array.
collection.CopyTo(declarations, 0)

' Retrieves the count of the items in the collection.
Dim collectionCount As Integer = collection.Count

' Inserts a CodeAttributeDeclaration at index 0 of the collection.
collection.Insert(0, New CodeAttributeDeclaration("DescriptionAttribute", New CodeAttributeArgument(New CodePrimitiveExpression("Test Description"))))

' Removes the specified CodeAttributeDeclaration from the collection.
Dim declaration As New CodeAttributeDeclaration("DescriptionAttribute", New CodeAttributeArgument(New CodePrimitiveExpression("Test Description")))
collection.Remove(declaration)

' Removes the CodeAttributeDeclaration at index 0.
collection.RemoveAt(0)
// Creates an empty CodeAttributeDeclarationCollection.
CodeAttributeDeclarationCollection collection = new CodeAttributeDeclarationCollection();

// Adds a CodeAttributeDeclaration to the collection.
collection.Add( new CodeAttributeDeclaration("DescriptionAttribute",  new CodeAttributeArgument(new CodePrimitiveExpression("Test Description"))) );

// Adds an array of CodeAttributeDeclaration objects 
// to the collection.
CodeAttributeDeclaration[] declarations = { new CodeAttributeDeclaration(), new CodeAttributeDeclaration() };
collection.AddRange( declarations );

// Adds a collection of CodeAttributeDeclaration objects 
// to the collection.
CodeAttributeDeclarationCollection declarationsCollection = new CodeAttributeDeclarationCollection();
declarationsCollection.Add( new CodeAttributeDeclaration("DescriptionAttribute", new CodeAttributeArgument(new CodePrimitiveExpression("Test Description"))) );
declarationsCollection.Add( new CodeAttributeDeclaration("BrowsableAttribute", new CodeAttributeArgument(new CodePrimitiveExpression(true))) );
collection.AddRange( declarationsCollection );

// Tests for the presence of a CodeAttributeDeclaration in 
// the collection, and retrieves its index if it is found.
CodeAttributeDeclaration testdeclaration = new CodeAttributeDeclaration("DescriptionAttribute", new CodeAttributeArgument(new CodePrimitiveExpression("Test Description")) );
int itemIndex = -1;
if( collection.Contains( testdeclaration ) )
    itemIndex = collection.IndexOf( testdeclaration );

// Copies the contents of the collection, beginning at index 0,
// to the specified CodeAttributeDeclaration array.
// 'declarations' is a CodeAttributeDeclaration array.
collection.CopyTo( declarations, 0 );

// Retrieves the count of the items in the collection.
int collectionCount = collection.Count;

// Inserts a CodeAttributeDeclaration at index 0 of the collection.
collection.Insert( 0, new CodeAttributeDeclaration("DescriptionAttribute", new CodeAttributeArgument(new CodePrimitiveExpression("Test Description"))) );

// Removes the specified CodeAttributeDeclaration from 
// the collection.
CodeAttributeDeclaration declaration = new CodeAttributeDeclaration("DescriptionAttribute", new CodeAttributeArgument(new CodePrimitiveExpression("Test Description")) );
collection.Remove( declaration );

// Removes the CodeAttributeDeclaration at index 0.
collection.RemoveAt(0);
// Creates an empty CodeAttributeDeclarationCollection.
CodeAttributeDeclarationCollection^ collection = gcnew CodeAttributeDeclarationCollection;

// Adds a CodeAttributeDeclaration to the collection.
array<CodeAttributeArgument^>^temp = {gcnew CodeAttributeArgument( gcnew CodePrimitiveExpression( "Test Description" ) )};
collection->Add( gcnew CodeAttributeDeclaration( "DescriptionAttribute",temp ) );

// Adds an array of CodeAttributeDeclaration objects 
// to the collection.
array<CodeAttributeDeclaration^>^declarations = {gcnew CodeAttributeDeclaration,gcnew CodeAttributeDeclaration};
collection->AddRange( declarations );

// Adds a collection of CodeAttributeDeclaration objects 
// to the collection.
CodeAttributeDeclarationCollection^ declarationsCollection = gcnew CodeAttributeDeclarationCollection;
array<CodeAttributeArgument^>^temp1 = {gcnew CodeAttributeArgument( gcnew CodePrimitiveExpression( "Test Description" ) )};
declarationsCollection->Add( gcnew CodeAttributeDeclaration( "DescriptionAttribute",temp1 ) );
array<CodeAttributeArgument^>^temp2 = {gcnew CodeAttributeArgument( gcnew CodePrimitiveExpression( true ) )};
declarationsCollection->Add( gcnew CodeAttributeDeclaration( "BrowsableAttribute",temp2 ) );
collection->AddRange( declarationsCollection );

// Tests for the presence of a CodeAttributeDeclaration in 
// the collection, and retrieves its index if it is found.
array<CodeAttributeArgument^>^temp3 = {gcnew CodeAttributeArgument( gcnew CodePrimitiveExpression( "Test Description" ) )};
CodeAttributeDeclaration^ testdeclaration = gcnew CodeAttributeDeclaration( "DescriptionAttribute",temp3 );
int itemIndex = -1;
if ( collection->Contains( testdeclaration ) )
   itemIndex = collection->IndexOf( testdeclaration );

// Copies the contents of the collection, beginning at index 0,
// to the specified CodeAttributeDeclaration array.
// 'declarations' is a CodeAttributeDeclaration array.
collection->CopyTo( declarations, 0 );

// Retrieves the count of the items in the collection.
int collectionCount = collection->Count;

// Inserts a CodeAttributeDeclaration at index 0 of the collection.
array<CodeAttributeArgument^>^temp4 = {gcnew CodeAttributeArgument( gcnew CodePrimitiveExpression( "Test Description" ) )};
collection->Insert( 0, gcnew CodeAttributeDeclaration( "DescriptionAttribute",temp4 ) );

// Removes the specified CodeAttributeDeclaration from 
// the collection.
array<CodeAttributeArgument^>^temp5 = {gcnew CodeAttributeArgument( gcnew CodePrimitiveExpression( "Test Description" ) )};
CodeAttributeDeclaration^ declaration = gcnew CodeAttributeDeclaration( "DescriptionAttribute",temp5 );
collection->Remove( declaration );

// Removes the CodeAttributeDeclaration at index 0.
collection->RemoveAt( 0 );
// Creates an empty CodeAttributeDeclarationCollection.
CodeAttributeDeclarationCollection collection =
    new CodeAttributeDeclarationCollection();

// Adds a CodeAttributeDeclaration to the collection.
collection.Add(new CodeAttributeDeclaration("DescriptionAttribute",
    new CodeAttributeArgument[] { new CodeAttributeArgument(
    new CodePrimitiveExpression("Test Description")) }));

// Adds an array of CodeAttributeDeclaration objects 
// to the collection.
CodeAttributeDeclaration declarations[] =  {
    new CodeAttributeDeclaration(),
    new CodeAttributeDeclaration() };
collection.AddRange(declarations);

// Adds a collection of CodeAttributeDeclaration objects 
// to the collection.
CodeAttributeDeclarationCollection declarationsCollection =
    new CodeAttributeDeclarationCollection();
declarationsCollection.Add(new CodeAttributeDeclaration(
    "DescriptionAttribute", new CodeAttributeArgument[] {
    new CodeAttributeArgument(new CodePrimitiveExpression(
    "Test Description")) }));
declarationsCollection.Add(new CodeAttributeDeclaration(
    "BrowsableAttribute", new CodeAttributeArgument[] {
    new CodeAttributeArgument(new CodePrimitiveExpression(
    (System.Boolean)true)) }));
collection.AddRange(declarationsCollection);

// Tests for the presence of a CodeAttributeDeclaration in 
// the collection, and retrieves its index if it is found.
CodeAttributeDeclaration testdeclaration =
    new CodeAttributeDeclaration("DescriptionAttribute",
    new CodeAttributeArgument[] { new CodeAttributeArgument(
    new CodePrimitiveExpression("Test Description")) });
int itemIndex = -1;
if (collection.Contains(testdeclaration)) {
    itemIndex = collection.IndexOf(testdeclaration);
}
// Copies the contents of the collection, beginning at index 0,
// to the specified CodeAttributeDeclaration array.
// 'declarations' is a CodeAttributeDeclaration array.
collection.CopyTo(declarations, 0);

// Retrieves the count of the items in the collection.
int collectionCount = collection.get_Count();

// Inserts a CodeAttributeDeclaration at index 0 of the collection.
collection.Insert(0, new CodeAttributeDeclaration(
    "DescriptionAttribute",new CodeAttributeArgument[] {
    new CodeAttributeArgument(new CodePrimitiveExpression(
    "Test Description")) }));

// Removes the specified CodeAttributeDeclaration from 
// the collection.
CodeAttributeDeclaration declaration =
    new CodeAttributeDeclaration("DescriptionAttribute",
    new CodeAttributeArgument[] { new CodeAttributeArgument(
    new CodePrimitiveExpression("Test Description")) });
collection.Remove(declaration);

// Removes the CodeAttributeDeclaration at index 0.
collection.RemoveAt(0);

継承階層

System.Object
   System.Collections.CollectionBase
    System.CodeDom.CodeAttributeDeclarationCollection

スレッド セーフ

この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。

プラットフォーム

Windows 98, Windows 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

開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。

バージョン情報

.NET Framework

サポート対象 : 2.0、1.1、1.0

参照

関連項目

CodeAttributeDeclarationCollection メンバ
System.CodeDom 名前空間
CodeAttributeDeclaration クラス