InstallerCollection.Contains-Methode
Bestimmt, ob das angegebene Installationsprogramm in der Auflistung enthalten ist.
Namespace: System.Configuration.Install
Assembly: System.Configuration.Install (in system.configuration.install.dll)
Syntax
'Declaration
Public Function Contains ( _
value As Installer _
) As Boolean
'Usage
Dim instance As InstallerCollection
Dim value As Installer
Dim returnValue As Boolean
returnValue = instance.Contains(value)
public bool Contains (
Installer value
)
public:
bool Contains (
Installer^ value
)
public boolean Contains (
Installer value
)
public function Contains (
value : Installer
) : boolean
Parameter
- value
Ein Installer, der das zu suchende Installationsprogramm darstellt.
Rückgabewert
true, wenn sich die angegebenen Installationsprogramme in dieser Auflistung befinden, andernfalls false.
Beispiel
Das folgende Beispiel veranschaulicht die Remove-Methode, die Contains-Methode und die IndexOf-Methode der InstallerCollection-Klasse. Dabei werden AssemblyInstaller-Instanzen für MyAssembly1.exe
und MyAssembly2.exe
erstellt. Diese Instanzen werden einem TransactedInstaller hinzugefügt. Anschließend wird MyAssembly2.exe
aus der InstallerCollection des TransactedInstaller entfernt. Der Installationsvorgang wird gestartet, und es wird lediglich MyAssembly1.exe
installiert.
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
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);
}
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.get_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.get_Installers().
Insert(1, myAssemblyInstaller2);
// Remove the 'myAssemblyInstaller2' from the
//'Installers' collection.
if (myTransactedInstaller.get_Installers().
Contains(myAssemblyInstaller2)) {
Console.WriteLine("\nInstaller at index : {0} is being removed",
System.Convert.ToString(
myTransactedInstaller.get_Installers().
IndexOf(myAssemblyInstaller2)));
myTransactedInstaller.get_Installers().
Remove(myAssemblyInstaller2);
}
.NET Framework-Sicherheit
- Volle Vertrauenswürdigkeit für den unmittelbaren Aufrufer. Dieser Member kann von nur teilweise vertrauenswürdigem Code nicht verwendet werden. Weitere Informationen finden Sie unter .
Plattformen
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 unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
InstallerCollection-Klasse
InstallerCollection-Member
System.Configuration.Install-Namespace
Add
AddRange
Remove
Installer-Klasse