InstallEventArgs クラスとは? わかりやすく解説

InstallEventArgs クラス

BeforeInstall、AfterInstall、Committing、Committed、BeforeRollback、AfterRollback、BeforeUninstall、AfterUninstall の各イベントデータ提供します

名前空間: System.Configuration.Install
アセンブリ: System.Configuration.Install (system.configuration.install.dll 内)
構文構文

Public Class InstallEventArgs
    Inherits EventArgs
Dim instance As InstallEventArgs
public class InstallEventArgs : EventArgs
public ref class InstallEventArgs : public
 EventArgs
public class InstallEventArgs extends EventArgs
public class InstallEventArgs extends
 EventArgs
解説解説

InstallEventArgs は、インストール現在の状態に関する情報保持する IDictionary を格納しますBeforeInstallAfterInstallCommittingCommittedBeforeRollbackAfterRollbackBeforeUninstallAfterUninstall の各イベント ハンドラは、この情報使用します

使用例使用例

InstallEventArgs クラスの InstallEventArgs コンストラクタおよび SavedState プロパティの例を次に示します

BeforeCommitAfterCommit という 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
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");
   }
}
#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)]
ref 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 += gcnew InstallEventHandler( this, &MyInstaller::BeforeCommitHandler
 );
      AfterCommit += gcnew InstallEventHandler( this, &MyInstaller::AfterCommitHandler
 );
   }

   virtual void Install( IDictionary^ savedState ) override
   {
      Installer::Install( savedState );
      Console::WriteLine( "Install ...\n" );
   }

   virtual void Commit( IDictionary^ savedState ) override
   {
      Console::WriteLine( "Before Committing ...\n" );
      // Call the 'OnBeforeCommit' protected method.
      OnBeforeCommit( savedState );
      Installer::Commit( savedState );
      Console::WriteLine( "Committing ...\n" );
      // Call the 'OnAfterCommit' protected method.
      OnAfterCommit( savedState );
      Console::WriteLine( "After Committing ...\n" );
   }

   virtual void Rollback( IDictionary^ savedState ) override
   {
      Installer::Rollback( savedState );
      Console::WriteLine( "RollBack ...\n" );
   }

   virtual void Uninstall( IDictionary^ savedState ) override
   {
      Installer::Uninstall( savedState );
      Console::WriteLine( "UnInstall ...\n" );
   }

   // Protected method that invoke the handlers associated with the
 'BeforeCommit' event.
protected:
   virtual void OnBeforeCommit( IDictionary^ savedState )
   {
      BeforeCommit( this, gcnew InstallEventArgs( savedState )
 );
   }

   // Protected method that invoke the handlers associated with the
 'AfterCommit' event.
protected:
   virtual void OnAfterCommit( IDictionary^ savedState )
   {
      AfterCommit( this, gcnew InstallEventArgs );
   }

   // A simple event handler to exemplify the example.
   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"
 );
   }
};
import System.*;
import System.ComponentModel.*;
import System.Collections.*;
import System.Configuration.Install.*;
import System.IO.*;

/** @attribute RunInstaller(true)
 */
public class MyInstaller extends Installer
{
    // Simple events to handle before and after commit handlers.
    public InstallEventHandler beforeCommit = null;
    public InstallEventHandler afterCommit = null;


    /** @event 
     */
    public void add_beforeCommitHandler(InstallEventHandler
 p)
    {
        beforeCommit = 
            (InstallEventHandler)System.Delegate.Combine(beforeCommit, p);
    }

    /** @event 
     */
    public void remove_beforeCommitHandler(InstallEventHandler
 p)
    {
        beforeCommit = 
            (InstallEventHandler)System.Delegate.Remove(beforeCommit, p);
    }

    /** @event 
     */
    public void add_afterCommitHandler(InstallEventHandler
 p)
    {
        afterCommit = 
            (InstallEventHandler)System.Delegate.Combine(afterCommit, p);
    }

    /** @event 
     */
    public void remove_afterCommitHandler(InstallEventHandler
 p)
    {
        afterCommit = 
            (InstallEventHandler)System.Delegate.Remove(afterCommit, p);
    }

    public MyInstaller()
    {
        // Add handlers to the events.
        add_beforeCommitHandler(new InstallEventHandler(BeforeCommitHandler));
        add_afterCommitHandler(new InstallEventHandler(AfterCommitHandler));
    } //MyInstaller

    public void Install(IDictionary savedState)
    {
        super.Install(savedState);
        Console.WriteLine("Install ...\n");
    } //Install

    public void Commit(IDictionary savedState)
    {
        Console.WriteLine("Before Committing ...\n");

        // Call the 'OnBeforeCommit' protected method.
        OnBeforeCommit(savedState);
        super.Commit(savedState);
        Console.WriteLine("Committing ...\n");

        // Call the 'OnAfterCommit' protected method.
        OnAfterCommit(savedState);
        Console.WriteLine("After Committing ...\n");
    } //Commit

    public void Rollback(IDictionary savedState)
    {
        super.Rollback(savedState);
        Console.WriteLine("RollBack ...\n");
    } //Rollback

    public void Uninstall(IDictionary savedState)
    {
        super.Uninstall(savedState);
        Console.WriteLine("UnInstall ...\n");
    } //Uninstall

    // Protected method that invoke the handlers associated 
    // with the 'BeforeCommit' event.
    protected void OnBeforeCommit(IDictionary
 savedState)
    {
        if (beforeCommit != null) {
            beforeCommit.Invoke(this, new InstallEventArgs(savedState));
        }
    } //OnBeforeCommit

    // Protected method that invoke the handlers associated 
    // with the 'AfterCommit' event.
    protected void OnAfterCommit(IDictionary
 savedState)
    {
        if (afterCommit != null) {
            afterCommit.Invoke(this, new InstallEventArgs());
        }
    } //OnAfterCommit

    // 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"
,
            System.Convert.ToString(e.get_SavedState().get_Count()));
    } //BeforeCommitHandler

    // A simple event handler to exemplify the example.
    private void AfterCommitHandler(Object sender,
 InstallEventArgs e)
    {
        Console.WriteLine("AfterCommitHandler event handler has been called\n");
    } //AfterCommitHandler
} //MyInstaller
継承階層継承階層
System.Object
   System.EventArgs
    System.Configuration.Install.InstallEventArgs
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
InstallEventArgs メンバ
System.Configuration.Install 名前空間
Installer.AfterInstall イベント
Installer.AfterRollback イベント
Installer.AfterUninstall イベント
Installer.BeforeInstall イベント
Installer.BeforeRollback イベント
Installer.BeforeUninstall イベント
Commit
Installer.Committed イベント
Installer.Committing イベント
Install
Installer クラス
InstallEventHandler
Rollback
Uninstall



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「InstallEventArgs クラス」の関連用語

InstallEventArgs クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



InstallEventArgs クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS