InstallerCollection.Contains(Installer) Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Determina se il programma di installazione specificato è incluso in questo insieme.
public:
bool Contains(System::Configuration::Install::Installer ^ value);
public bool Contains (System.Configuration.Install.Installer value);
member this.Contains : System.Configuration.Install.Installer -> bool
Public Function Contains (value As Installer) As Boolean
Parametri
Restituisce
true
se il programma di installazione specificato è contenuto nell'insieme, in caso contrario false
.
Esempio
Nell'esempio seguente viene illustrato il metodo, Contains il metodo e IndexOf il RemoveInstallerCollection metodo della classe. Crea AssemblyInstaller istanze per MyAssembly1.exe
e MyAssembly2.exe
. Queste istanze vengono aggiunte a un TransactedInstalleroggetto . MyAssembly2.exe
viene quindi rimosso dall'oggetto dell'oggetto InstallerCollectionTransactedInstaller. Il processo di installazione avvia e installa solo MyAssembly1.exe
.
TransactedInstaller^ myTransactedInstaller = gcnew TransactedInstaller;
AssemblyInstaller^ myAssemblyInstaller1;
AssemblyInstaller^ myAssemblyInstaller2;
InstallContext^ myInstallContext;
// Create a instance of 'AssemblyInstaller' that installs 'MyAssembly1.exe'.
myAssemblyInstaller1 = gcnew AssemblyInstaller( "MyAssembly1.exe",nullptr );
// Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'.
myTransactedInstaller->Installers->Insert( 0, myAssemblyInstaller1 );
// Create a instance of 'AssemblyInstaller' that installs 'MyAssembly2.exe'.
myAssemblyInstaller2 = gcnew AssemblyInstaller( "MyAssembly2.exe",nullptr );
// Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'.
myTransactedInstaller->Installers->Insert( 1, myAssemblyInstaller2 );
// Remove the 'myAssemblyInstaller2' from the 'Installers' collection.
if ( myTransactedInstaller->Installers->Contains( myAssemblyInstaller2 ) )
{
Console::WriteLine( "\nInstaller at index : {0} is being removed", myTransactedInstaller->Installers->IndexOf( myAssemblyInstaller2 ) );
myTransactedInstaller->Installers->Remove( myAssemblyInstaller2 );
}
TransactedInstaller myTransactedInstaller = new TransactedInstaller();
AssemblyInstaller myAssemblyInstaller1;
AssemblyInstaller myAssemblyInstaller2;
InstallContext myInstallContext;
// Create a instance of 'AssemblyInstaller' that installs 'MyAssembly1.exe'.
myAssemblyInstaller1 =
new AssemblyInstaller("MyAssembly1.exe", null);
// Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'.
myTransactedInstaller.Installers.Insert(0, myAssemblyInstaller1);
// Create a instance of 'AssemblyInstaller' that installs 'MyAssembly2.exe'.
myAssemblyInstaller2 =
new AssemblyInstaller("MyAssembly2.exe", null);
// Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'.
myTransactedInstaller.Installers.Insert(1, myAssemblyInstaller2);
// Remove the 'myAssemblyInstaller2' from the 'Installers' collection.
if(myTransactedInstaller.Installers.Contains(myAssemblyInstaller2))
{
Console.WriteLine("\nInstaller at index : {0} is being removed",
myTransactedInstaller.Installers.IndexOf(myAssemblyInstaller2));
myTransactedInstaller.Installers.Remove(myAssemblyInstaller2);
}
Dim myTransactedInstaller As New TransactedInstaller()
Dim myAssemblyInstaller1 As AssemblyInstaller
Dim myAssemblyInstaller2 As AssemblyInstaller
Dim myInstallContext As InstallContext
' Create a instance of 'AssemblyInstaller' that installs 'MyAssembly1.exe'.
myAssemblyInstaller1 = New AssemblyInstaller("MyAssembly1.exe", Nothing)
' Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'.
myTransactedInstaller.Installers.Insert(0, myAssemblyInstaller1)
' Create a instance of 'AssemblyInstaller' that installs 'MyAssembly2.exe'.
myAssemblyInstaller2 = New AssemblyInstaller("MyAssembly2.exe", Nothing)
' Add the instance of 'AssemblyInstaller' to the 'TransactedInstaller'.
myTransactedInstaller.Installers.Insert(1, myAssemblyInstaller2)
' Remove the 'myAssemblyInstaller2' from the 'Installers' collection.
If myTransactedInstaller.Installers.Contains(myAssemblyInstaller2) Then
Console.WriteLine(ControlChars.Newline + "Installer at index : {0} is being removed", _
myTransactedInstaller.Installers.IndexOf(myAssemblyInstaller2))
myTransactedInstaller.Installers.Remove(myAssemblyInstaller2)
End If