This documentation is archived and is not being maintained.

ResolveNameEventHandler Delegate

Represents the method that handles the ResolveName event of a serialization manager.

[Visual Basic]
<Serializable>
Public Delegate Sub ResolveNameEventHandler( _
   ByVal sender As Object, _
   ByVal e As ResolveNameEventArgs _
)
[C#]
[Serializable]
public delegate void ResolveNameEventHandler(
   object sender,
   ResolveNameEventArgs e
);
[C++]
[Serializable]
public __gc __delegate void ResolveNameEventHandler(
   Object* sender,
   ResolveNameEventArgs* e
);

[JScript] In JScript, you can use the delegates in the .NET Framework, but you cannot define your own.

Parameters [Visual Basic, C#, C++]

The declaration of your event handler must have the same parameters as the ResolveNameEventHandler delegate declaration.

Remarks

This delegate is used by the IDesignerSerializationManager to resolve object names during serialization and deserialization.

When you create a ResolveNameEventHandler delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event-handler delegates, see Events and Delegates.

Example

[Visual Basic, C#, C++] The following code example attaches a ResolveNameEventHandler to the ResolveName event of a specified IDesignerSerializationManager.

[Visual Basic] 
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

[C#] 
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());            
}

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

private:
    void OnResolveName(Object* /*sender*/, ResolveNameEventArgs* e) {
        // Displays ResolveName event information on the console.
        Console::WriteLine(S"Name of the name to resolve: {0}", e->Name);
        Console::WriteLine(S"ToString output of the Object that no name was resolved for: {0}", e->Value);
    }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.ComponentModel.Design.Serialization

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: System (in System.dll)

See Also

System.ComponentModel.Design.Serialization Namespace | IDesignerSerializationManager | ResolveNameEventArgs | ResolveName

Show: