Bagikan melalui


ResolveNameEventHandler Delegasikan

Definisi

Mewakili metode yang menangani ResolveName peristiwa manajer serialisasi.

public delegate void ResolveNameEventHandler(System::Object ^ sender, ResolveNameEventArgs ^ e);
public delegate void ResolveNameEventHandler(object sender, ResolveNameEventArgs e);
public delegate void ResolveNameEventHandler(object? sender, ResolveNameEventArgs e);
type ResolveNameEventHandler = delegate of obj * ResolveNameEventArgs -> unit
Public Delegate Sub ResolveNameEventHandler(sender As Object, e As ResolveNameEventArgs)

Parameter

sender
Object

Sumber dari peristiwa tersebut.

e
ResolveNameEventArgs

ResolveNameEventArgs yang berisi data peristiwa.

Contoh

Contoh kode berikut melampirkan ResolveNameEventHandler ke ResolveName peristiwa dari yang ditentukan IDesignerSerializationManager.

public:
   void LinkResolveNameEvent( IDesignerSerializationManager^ serializationManager )
   {
      // Registers an event handler for the ResolveName event.
      serializationManager->ResolveName +=
         gcnew ResolveNameEventHandler( this, &Form1::OnResolveName );
   }

private:
   void OnResolveName( Object^ sender, ResolveNameEventArgs^ e )
   {
      // Displays ResolveName event information on the console.
      Console::WriteLine( "Name of the name to resolve: " + e->Name );
      Console::WriteLine( "ToString output of the Object that no name was resolved for: " +
         e->Value );
   }
public void LinkResolveNameEvent(
        IDesignerSerializationManager serializationManager)
{
    // Registers an event handler for the ResolveName event.
    serializationManager.ResolveName += 
        new ResolveNameEventHandler(this.OnResolveName);
}

private void OnResolveName(object sender, ResolveNameEventArgs e)
{                        
    // Displays ResolveName event information on the console. 
    Console.WriteLine("Name of the name to resolve: "+e.Name);
    Console.WriteLine("ToString output of the object that no name was resolved for: "+e.Value.ToString());            
}
Public Sub LinkResolveNameEvent(ByVal serializationManager As IDesignerSerializationManager)
    ' Registers an event handler for the resolve name event.
    AddHandler serializationManager.ResolveName, AddressOf Me.OnResolveName
End Sub

Private Sub OnResolveName(ByVal sender As Object, ByVal e As ResolveNameEventArgs)
    ' Displays ResolveName event information on the Console.
    Console.WriteLine(("Name of the name to resolve: " + e.Name))
    Console.WriteLine(("ToString output of the object that no name was resolved for: " + e.Value.ToString()))
End Sub

Keterangan

Delegasi ini digunakan oleh IDesignerSerializationManager untuk mengatasi nama objek selama serialisasi dan deserialisasi.

Saat membuat ResolveNameEventHandler delegasi, Anda mengidentifikasi metode yang akan menangani peristiwa. Untuk mengaitkan peristiwa dengan penanganan aktivitas Anda, tambahkan instans delegasi ke peristiwa. Penanganan aktivitas dipanggil setiap kali peristiwa terjadi, kecuali Jika Anda menghapus delegasi. Untuk informasi selengkapnya tentang delegasi penanganan aktivitas, lihat Menangani dan Meningkatkan Peristiwa.

Metode Ekstensi

GetMethodInfo(Delegate)

Mendapatkan objek yang mewakili metode yang diwakili oleh delegasi yang ditentukan.

Berlaku untuk

Lihat juga