Drawing3d documented Class Library

NicerXMLFormatter.StringConverter Property

With the StringConverter you can convert objects to a string. If you do this, the object has the behavior of a primitiv object. The avantage is also, that the XML is better to read. For example: if you have a object Point with the fields X and Y ( of type int) you get the XML source like

 <field type:Point > <X>3</X> <Y>5</Y> </field> 
You can make your own Stringconverter like this:
 public class MyStringConverter:CustomStringConverter { public override bool CanConvert(Type Type) { if (base.Convert(Type)) return true; if (Type == typeof(Point)) return true; if (Type == typeof(Color)) return true; return false; } public override string ConvertToString(object Value, Type Type) { if (base.Convert(Type)) return base.ConvertToString(value,Type); if (Type == typeof(Point)) return (Point.X.ToString)+","+(Point.y.ToString); if (Type == typeof(Color)) return new ColorConverter().ConvertToString(Value); return ""; } public override object ConvertFromString(String Value, Type Type) { if (base.CanConvert(Type)) return base.ConvertFromString(Value,Type); if (Type == typeof(Point)) { string[] S = Value.Split(','); return new Point(Convert.ToInt32(S[0]), Convert.ToInt32(S[1])); } if (Type == typeof(Color)) return new ColorConverter().ConvertFromString(Value); return false; } } 
You have to set this in the StringConverter property: StringConverter = new MyStringConverter;

[Visual Basic]
Public Property StringConverter() As CustomStringConverter
   Public Get
   End Get
   Public Set
   End Set
End Property
[C#]
public CustomStringConverter StringConverter { public get; public set; }

See Also

NicerXMLFormatter Class | Drawing3d Namespace