InstallEventArgs クラス
BeforeInstall 、 AfterInstall 、 Committing 、 Committed 、 BeforeRollback 、 AfterRollback 、 BeforeUninstall 、 AfterUninstall の各イベントのデータを提供します。
この型のすべてのメンバの一覧については、InstallEventArgs メンバ を参照してください。
System.Object
System.EventArgs
System.Configuration.Install.InstallEventArgs
Public Class InstallEventArgs
Inherits EventArgs
[C#]
public class InstallEventArgs : EventArgs
[C++]
public __gc class InstallEventArgs : public EventArgs
[JScript]
public class InstallEventArgs extends EventArgs
スレッドセーフ
この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。
解説
InstallEventArgs は、インストールの現在の状態に関する情報を保持する IDictionary を格納します。 BeforeInstall 、 AfterInstall 、 Committing 、 Committed 、 BeforeRollback 、 AfterRollback 、 BeforeUninstall 、 AfterUninstall の各イベント ハンドラは、この情報を使用します。
使用例
[Visual Basic, C#, C++] InstallEventArgs クラスの InstallEventArgs コンストラクタおよび SavedState プロパティの例を次に示します。
[Visual Basic, C#, C++] BeforeCommit
と AfterCommit
という 2 つの新しいイベントがあります。これらのイベントのハンドラは、それぞれ OnBeforeCommit
および OnAfterCommit
という名前のプロテクト メソッドから呼び出されます。これらのイベントは、 Commit メソッドが呼び出されたときに発生します。
Imports System
Imports System.ComponentModel
Imports System.Collections
Imports System.Configuration.Install
Imports System.IO
Imports Microsoft.VisualBasic
<RunInstaller(True)> Public Class MyInstaller
Inherits Installer
' Simple events to handle before and after commit handlers.
Public Event BeforeCommit As InstallEventHandler
Public Event AfterCommit As InstallEventHandler
Public Sub New()
' Add handlers to the events.
AddHandler BeforeCommit, AddressOf BeforeCommitHandler
AddHandler AfterCommit, AddressOf AfterCommitHandler
End Sub
Public Overrides Sub Install(savedState As IDictionary)
MyBase.Install(savedState)
Console.WriteLine("Install ..." + ControlChars.Newline)
End Sub
Public Overrides Sub Commit(savedState As IDictionary)
Console.WriteLine("Before Committing ..." + ControlChars.Newline)
' Call the 'OnBeforeCommit' protected method.
OnBeforeCommit(savedState)
MyBase.Commit(savedState)
Console.WriteLine("Committing ..." + ControlChars.Newline)
' Call the 'OnAfterCommit' protected method.
OnAfterCommit(savedState)
Console.WriteLine("After Committing ..." + ControlChars.Newline)
End Sub
Public Overrides Sub Rollback(savedState As IDictionary)
MyBase.Rollback(savedState)
Console.WriteLine("RollBack ..." + ControlChars.Newline)
End Sub
Public Overrides Sub Uninstall(savedState As IDictionary)
MyBase.Uninstall(savedState)
Console.WriteLine("UnInstall ..." + ControlChars.Newline)
End Sub
' Protected method that invoke the handlers associated with the 'BeforeCommit' event.
Protected Overridable Sub OnBeforeCommit(savedState As IDictionary)
RaiseEvent BeforeCommit(Me, New InstallEventArgs(savedState))
End Sub
' Protected method that invoke the handlers associated with the 'AfterCommit' event.
Protected Overridable Sub OnAfterCommit(savedState As IDictionary)
RaiseEvent AfterCommit(Me, New InstallEventArgs())
End Sub
' A simple event handler to exemplify the example.
Private Sub BeforeCommitHandler(sender As Object, e As InstallEventArgs)
Console.WriteLine("BeforeCommitHandler event handler has been called" + _
ControlChars.Newline)
Console.WriteLine("The count of saved state objects are : {0}" + _
ControlChars.Newline, e.SavedState.Count)
End Sub
' A simple event handler to exemplify the example.
Private Sub AfterCommitHandler(sender As Object, e As InstallEventArgs)
Console.WriteLine("AfterCommitHandler event handler has been called" + _
ControlChars.Newline)
End Sub
End Class
[C#]
using System;
using System.ComponentModel;
using System.Collections;
using System.Configuration.Install;
using System.IO;
[RunInstaller(true)]
public class MyInstaller : Installer
{
// Simple events to handle before and after commit handlers.
public event InstallEventHandler BeforeCommit;
public event InstallEventHandler AfterCommit;
public MyInstaller()
{
// Add handlers to the events.
BeforeCommit += new InstallEventHandler(BeforeCommitHandler);
AfterCommit += new InstallEventHandler(AfterCommitHandler);
}
public override void Install(IDictionary savedState)
{
base.Install(savedState);
Console.WriteLine("Install ...\n");
}
public override void Commit(IDictionary savedState)
{
Console.WriteLine("Before Committing ...\n");
// Call the 'OnBeforeCommit' protected method.
OnBeforeCommit(savedState);
base.Commit(savedState);
Console.WriteLine("Committing ...\n");
// Call the 'OnAfterCommit' protected method.
OnAfterCommit(savedState);
Console.WriteLine("After Committing ...\n");
}
public override void Rollback(IDictionary savedState)
{
base.Rollback(savedState);
Console.WriteLine("RollBack ...\n");
}
public override void Uninstall(IDictionary savedState)
{
base.Uninstall(savedState);
Console.WriteLine("UnInstall ...\n");
}
// Protected method that invoke the handlers associated with the 'BeforeCommit' event.
protected virtual void OnBeforeCommit(IDictionary savedState)
{
if(BeforeCommit != null)
BeforeCommit(this, new InstallEventArgs(savedState));
}
// Protected method that invoke the handlers associated with the 'AfterCommit' event.
protected virtual void OnAfterCommit(IDictionary savedState)
{
if(AfterCommit != null)
AfterCommit(this, new InstallEventArgs());
}
// A simple event handler to exemplify the example.
private void BeforeCommitHandler(Object sender, InstallEventArgs e)
{
Console.WriteLine("BeforeCommitHandler event handler has been called\n");
Console.WriteLine("The count of saved state objects are : {0}\n",
e.SavedState.Count);
}
// A simple event handler to exemplify the example.
private void AfterCommitHandler(Object sender, InstallEventArgs e)
{
Console.WriteLine("AfterCommitHandler event handler has been called\n");
}
}
[C++]
#using <mscorlib.dll>
#using <System.dll>
#using <System.Configuration.Install.dll>
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Configuration::Install;
using namespace System::IO;
[RunInstaller(true)]
__gc class MyInstaller : public Installer {
public:
// Simple events to handle before and after commit handlers.
__event InstallEventHandler* BeforeCommit;
__event InstallEventHandler* AfterCommit;
MyInstaller() {
// Add handlers to the events.
BeforeCommit += new InstallEventHandler(this, &MyInstaller::BeforeCommitHandler);
AfterCommit += new InstallEventHandler(this, &MyInstaller::AfterCommitHandler);
}
void Install(IDictionary* savedState) {
Installer::Install(savedState);
Console::WriteLine(S"Install ...\n");
}
void Commit(IDictionary* savedState) {
Console::WriteLine(S"Before Committing ...\n");
// Call the 'OnBeforeCommit' protected method.
OnBeforeCommit(savedState);
Installer::Commit(savedState);
Console::WriteLine(S"Committing ...\n");
// Call the 'OnAfterCommit' protected method.
OnAfterCommit(savedState);
Console::WriteLine(S"After Committing ...\n");
}
void Rollback(IDictionary* savedState) {
Installer::Rollback(savedState);
Console::WriteLine(S"RollBack ...\n");
}
void Uninstall(IDictionary* savedState) {
Installer::Uninstall(savedState);
Console::WriteLine(S"UnInstall ...\n");
}
protected:
// Protected method that invoke the handlers associated with the 'BeforeCommit' event.
virtual void OnBeforeCommit(IDictionary* savedState) {
if (BeforeCommit)
BeforeCommit(this, new InstallEventArgs(savedState));
}
// Protected method that invoke the handlers associated with the 'AfterCommit' event.
virtual void OnAfterCommit(IDictionary* savedState) {
if (AfterCommit)
AfterCommit(this, new InstallEventArgs());
}
// A simple event handler to exemplify the example.
void BeforeCommitHandler(Object* sender, InstallEventArgs* e) {
Console::WriteLine(S"BeforeCommitHandler event handler has been called\n");
Console::WriteLine(S"The count of saved state objects are : {0}\n",
__box(e->SavedState->Count));
}
// A simple event handler to exemplify the example.
void AfterCommitHandler(Object* sender, InstallEventArgs* e) {
Console::WriteLine(S"AfterCommitHandler event handler has been called\n");
}
};
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
名前空間: System.Configuration.Install
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
アセンブリ: System.Configuration.Install (System.Configuration.Install.dll 内)
参照
InstallEventArgs メンバ | System.Configuration.Install 名前空間 | AfterInstall | AfterRollback | AfterUninstall | BeforeInstall | BeforeRollback | BeforeUninstall | Commit | Committed | Committing | Install | Installer | InstallEventHandler | Rollback | Uninstall