InstallerCollection.Contains Method
Determines whether the specified installer is included in collection.
Namespace: System.Configuration.Install
Assembly: System.Configuration.Install (in System.Configuration.Install.dll)
Parameters
- value
- Type: System.Configuration.Install.Installer
An Installer that represents the installer to look for.
Return Value
Type: System.Booleantrue if the specified installer is in this collection; otherwise, false.
The following example demonstrates the Remove method, Contains method, and IndexOf method of the InstallerCollection class. It creates AssemblyInstaller instances for MyAssembly1.exe and MyAssembly2.exe. These instances are added to a TransactedInstaller. MyAssembly2.exe is then removed from the InstallerCollection of the TransactedInstaller. The installation process starts and installs only MyAssembly1.exe.
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); }
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.