It is possible to save a diagram as an XML document. To do that, call the SaveToXml method of the Diagram class. To deserialize a diagram back from its XML representation, call the LoadFromXml method.
Custom item classes can implement XML serialization for their additional properties by overriding the SaveToXml and LoadFromXml methods. In addition, such classes must specify a string to use as their identifier in the XML document by calling RegisterItemClass.
The control raises SerializeTag and DeserializeTag to enable serialization of complex Id and Tag objects without overriding the item classes. The PropertyName event argument specifies which property is being serialized.
Custom item classes can implement JSON serialization for their additional properties by overriding the SaveToJson and LoadFromJson methods. Such classes must be registered for serialization by calling the RegisterItemClass method and providing a string identifier for the clientClass parameter.
The control raises JsonSerializeTag and JsonDeserializeTag to enable serialization of complex Id and Tag objects without overriding the item classes. The PropertyName event argument specifies which property is being serialized.
JSON serialization is handled internally by the classes from MindFusion.Json.Wpf namespace. The JsonValue class represents a property value. Property names and values are stored in instances of the JsonObject dictionary class. The JsonContext class handles the serialization of the Diagram properties. The Serialize method is a wrapper over the Serializer class' Serialize method. It takes a JsonObject and serializes it to a string. The Parse method is a wrapper over the Parser class' ReadJsonObject method. It takes a JSON-formatted string and returns a JsonObject with the parsed data.