다음을 통해 공유


InstallerCollection.CopyTo(Installer[], Int32) 메서드

정의

지정된 인덱스에서 시작하여 컬렉션에서 배열로 항목을 복사합니다.

public:
 void CopyTo(cli::array <System::Configuration::Install::Installer ^> ^ array, int index);
public void CopyTo (System.Configuration.Install.Installer[] array, int index);
member this.CopyTo : System.Configuration.Install.Installer[] * int -> unit
Public Sub CopyTo (array As Installer(), index As Integer)

매개 변수

array
Installer[]

복사할 대상 배열입니다.

index
Int32

컬렉션을 붙여넣을 배열의 인덱스입니다.

예제

다음 예제에서는 클래스의 CopyTo 메서드를 보여 줍니다 InstallerCollection . 및 MyAssembly2.exe에 대한 인스턴스를 MyAssembly1.exe 만듭니다AssemblyInstaller. 이러한 인스턴스는 에 TransactedInstaller추가됩니다. 설치할 어셈블리의 이름이 콘솔에 표시됩니다. 설치 프로세스는 및 MyAssembly2.exe를 모두 MyAssembly1.exe 설치합니다.

TransactedInstaller^ myTransactedInstaller = gcnew TransactedInstaller;
AssemblyInstaller^ myAssemblyInstaller;
InstallContext^ myInstallContext;

// Create an instance of 'AssemblyInstaller' that installs 'MyAssembly1.exe'.
myAssemblyInstaller =
   gcnew AssemblyInstaller( "MyAssembly1.exe",nullptr );

// Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'.
myTransactedInstaller->Installers->Add( myAssemblyInstaller );

// Create an instance of 'AssemblyInstaller' that installs 'MyAssembly2.exe'.
myAssemblyInstaller =
   gcnew AssemblyInstaller( "MyAssembly2.exe",nullptr );

// Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'.
myTransactedInstaller->Installers->Add( myAssemblyInstaller );

array<Installer^>^ myInstallers =
   gcnew array<Installer^>(myTransactedInstaller->Installers->Count);

myTransactedInstaller->Installers->CopyTo( myInstallers, 0 );
// Print the assemblies to be installed.
Console::WriteLine( "Printing all assemblies to be installed -" );
for ( int i = 0; i < myInstallers->Length; i++ )
{
   if ( dynamic_cast<AssemblyInstaller^>( myInstallers[ i ] ) )
   {
      Console::WriteLine( "{0} {1}", i + 1, ( (AssemblyInstaller^)( myInstallers[ i ]) )->Path );
   }
}
TransactedInstaller myTransactedInstaller = new TransactedInstaller();
AssemblyInstaller myAssemblyInstaller;
InstallContext myInstallContext;

// Create an instance of 'AssemblyInstaller' that installs 'MyAssembly1.exe'.
myAssemblyInstaller =
   new AssemblyInstaller("MyAssembly1.exe", null);

// Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'.
myTransactedInstaller.Installers.Add(myAssemblyInstaller);

// Create an instance of 'AssemblyInstaller' that installs 'MyAssembly2.exe'.
myAssemblyInstaller =
   new AssemblyInstaller("MyAssembly2.exe", null);

// Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'.
myTransactedInstaller.Installers.Add(myAssemblyInstaller);

Installer[] myInstallers =
   new Installer[myTransactedInstaller.Installers.Count];

myTransactedInstaller.Installers.CopyTo(myInstallers, 0);
// Print the assemblies to be installed.
Console.WriteLine("Printing all assemblies to be installed -");
for(int i = 0; i < myInstallers.Length; i++)
{
   if((myInstallers[i].GetType()).Equals(typeof(AssemblyInstaller)))
   {
      Console.WriteLine("{0} {1}", i + 1,
         ((AssemblyInstaller)myInstallers[i]).Path);
   }
}
Dim myTransactedInstaller As New TransactedInstaller()
Dim myAssemblyInstaller As AssemblyInstaller
Dim myInstallContext As InstallContext

' Create an instance of 'AssemblyInstaller' that installs 'MyAssembly1.exe'.
myAssemblyInstaller = New AssemblyInstaller("MyAssembly1.exe", Nothing)

' Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'.
myTransactedInstaller.Installers.Add(myAssemblyInstaller)

' Create an instance of 'AssemblyInstaller' that installs 'MyAssembly2.exe'.
myAssemblyInstaller = New AssemblyInstaller("MyAssembly2.exe", Nothing)

' Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'.
myTransactedInstaller.Installers.Add(myAssemblyInstaller)

Dim myInstallers(myTransactedInstaller.Installers.Count-1) As Installer

myTransactedInstaller.Installers.CopyTo(myInstallers, 0)
' Print the assemblies to be installed.
Console.WriteLine("Printing all assemblies to be installed -")
Dim i As Integer
For i = 0 To myInstallers.Length - 1
   If myInstallers(i).GetType().Equals(GetType(AssemblyInstaller)) Then
      Console.WriteLine("{0} {1}", i + 1, CType(myInstallers(i), AssemblyInstaller).Path)
   End If
Next i

적용 대상