Partilhar via


ResolveNameEventHandler Delegar

Definição

Representa o método que manipula o evento ResolveName de um gerenciador de serialização.

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)

Parâmetros

sender
Object

A fonte do evento.

e
ResolveNameEventArgs

Um ResolveNameEventArgs que contém os dados do evento.

Exemplos

O exemplo de código a seguir anexa um ResolveNameEventHandler ao ResolveName evento de um especificado 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

Comentários

Esse delegado é usado pelo IDesignerSerializationManager para resolve nomes de objeto durante a serialização e desserialização.

Ao criar um ResolveNameEventHandler delegado, você identifica o método que manipulará o evento. Para associar o evento ao manipulador de eventos, adicione uma instância do delegado ao evento. O manipulador de eventos é chamado sempre que o evento ocorre, a menos que você remova o representante. Para obter mais informações sobre delegados do manipulador de eventos, consulte Manipulando e gerando eventos.

Métodos de Extensão

GetMethodInfo(Delegate)

Obtém um objeto que representa o método representado pelo delegado especificado.

Aplica-se a

Confira também