指定したインストーラがコレクション内にあるかどうかを確認します。
Public Function Contains( _
ByVal value As Installer _) As Boolean
[C#]
public bool Contains(Installervalue);
[C++]
public: bool Contains(Installer* value);
[JScript]
public function Contains(
value : Installer) : Boolean;
パラメータ
- value
検索対象のインストーラを表す Installer 。
戻り値
指定したインストーラがコレクションにある場合は true 。それ以外の場合は false 。
使用例
[Visual Basic, C#, C++] InstallerCollection クラスの Remove メソッド、 Contains メソッド、および IndexOf メソッドの例を次に示します。これは MyAssembly1.exe
および MyAssembly2.exe
の AssemblyInstaller インスタンスを作成します。これらのインスタンスは、 TransactedInstaller に追加されます。 MyAssembly2.exe
は次に、 TransactedInstaller の InstallerCollection から削除されます。インストール プロセスが開始され、 MyAssembly1.exe
だけをインストールします。
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
[C#]
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);
}
[C++]
TransactedInstaller* myTransactedInstaller = new TransactedInstaller();
AssemblyInstaller* myAssemblyInstaller1;
AssemblyInstaller* myAssemblyInstaller2;
InstallContext* myInstallContext;
// Create a instance of 'AssemblyInstaller' that installs 'MyAssembly1.exe'.
myAssemblyInstaller1 = new AssemblyInstaller(S"MyAssembly1.exe", 0);
// 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(S"MyAssembly2.exe", 0);
// 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(S"\nInstaller at index : {0} is being removed",
__box(myTransactedInstaller->Installers->IndexOf(myAssemblyInstaller2)));
myTransactedInstaller->Installers->Remove(myAssemblyInstaller2);
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
.NET Framework セキュリティ:
- 直前の呼び出し元の完全信頼。このメンバは、部分的に信頼されているコードから使用することはできません。詳細の参照先 : 部分信頼コードからのライブラリの使用
参照
InstallerCollection クラス | InstallerCollection メンバ | System.Configuration.Install 名前空間 | Add | AddRange | Remove | Installer