Articles in this section
Category / Section

How can I serialize the custom property of a node?

4 mins read

Serialize custom property of a node

Essential® Diagram supports custom serialization. To serialize a custom property, you need to derive the Group class and create a custom node. You must override the GetObjectData() method, where you can add the custom property in the SerializationInfo. Please refer to the code snippet below.

 

C#

[Serializable()]
public class CustomNode : Group
{
protected CustomNode(SerializationInfo info, StreamingContext context) : base(info, context)
{
this.m_nodeInformation = info.GetString("strDescription");
}
protected override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
// Additional member variables are serialized here
info.AddValue("strDescription", this.NodeInformation);
}
}
 


VB

 

<Serializable()> _
Public Class CustomNode
Inherits Group
Public Sub New()
End Sub
Protected Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)
MyBase.New(info, context)
Me.m_nodeInformation = info.GetString("strDescription")
End Sub
Protected Overrides Sub GetObjectData(ByVal info As SerializationInfo, ByVal context As StreamingContext)
MyBase.GetObjectData(info, context)
' Additional member variables are serialized here
info.AddValue("strDescription", Me.NodeInformation)
End Sub
End Class
 

 

Please refer to the attached sample that illustrates this.

https://help.syncfusion.com/support/samples/kb/Diagram.Windows/Diagram_WF_SerializeProperty/Diagram_WF_SerializeProperty.zip 


Conclusion

I hope you enjoyed learning about how can I serialize the custom property of a node.

You can refer to our WinForms Diagram feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our 
WinForms Diagram example
 to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusio, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied