共用方式為


ResolveNameEventHandler 代理人

定義

表示處理序列化 (Serialization) 管理員的 ResolveName 事件的方法。

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)

參數

sender
Object

事件的來源。

e
ResolveNameEventArgs

ResolveNameEventArgs,其中包含事件資料。

範例

下列程式代碼範例會將 ResolveNameEventHandler 附加至 ResolveName 指定 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

備註

這個委派是由 用來 IDesignerSerializationManager 解析串行化和還原串行化期間的物件名稱。

建立 ResolveNameEventHandler 委派時,必須識別處理事件的方法。 若要使事件與您的事件處理常式產生關聯,請將委派的執行個體 (Instance) 加入至事件。 除非您移除委派,否則每當事件發生時就會呼叫事件處理常式。 如需事件處理程式委派的詳細資訊,請參閱 處理和引發事件

擴充方法

GetMethodInfo(Delegate)

取得表示特定委派所代表之方法的物件。

適用於

另請參閱