Search
DiagramItem.Id Property
See Also
 





Gets or sets user-defined identifier associated with this item.

Namespace: MindFusion.Diagramming
Assembly: MindFusion.Diagramming

 Syntax

C#  Copy Code

public Object Id { get; set; }

Visual Basic  Copy Code

Public Property Id As Object

 Property Value

An instance of any class derived from System.Object.

 Remarks

This property contains user-defined data and is not used by the component in any way. You can associate any value with the item, including primitive data types, objects from the .NET class library, or instances of custom types.

If the id value is of a primitive type, it is serialized directly by the component along with the item that contains it when the diagram is saved or loaded. Custom types can be serialized automatically depending on the target format:

  • Binary format: Id objects are saved using BinaryFormatter if they are marked with the [Serializable] attribute or implement the ISerializable interface. Note that BinaryFormatter is deprecated in newer .NET versions and, as of .NET 10, can only be used via a NuGet package;
  • XML format: Custom types are serialized using System.Xml.Serialization.XmlSerializer;
  • JSON format: Custom types are serialized using System.Text.Json.JsonSerializer when running on .NET 5 or later. (JsonSerializer is not available out of the box in .NET 4 and earlier versions.)

You can also implement custom serialization logic by handling the SerializeTag and DeserializeTag events using the .NET XML API, or the JsonSerializeTag and JsonDeserializeTag events using the MindFusion.Json API.

 See Also