Help!!!
I need to create a serializable (xml style) class to write it on a DB field (type memo/text on sql).
This class contains a collection. To understand i have a db of similar things with a Levels field. Here i want store the level structure, style xml.
<Level1 name="">
<level2 name=""></level2>
</Level1>
Give me some indications to write this class and some code to start, please.
Thx

serializable class
alvinjames
In .net framework we get some things for free!
You can use the default serialization:
System.Xml.Serialization.XmlSerializer
You can custom the serialization operation using attributes, such as
System.Xml.Serialization.
XmlIgnoreAttributeSystem.Xml.Serialization.
XmlElementAttributeVBVBVB
Hi!
You can use this for a start.
public
class Style{
XmlAttribute] public string FontName;[
XmlAttribute] public int Color;[
XmlArray] public List<Style> Children = new List<Style>(); public Style FromXml(string fileName){
using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read)){
return new XmlSerializer(typeof(Style)).Deserialize(stream) as Style;}
}
public void SaveXml(string fileName){
using (FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write)){
new XmlSerializer(typeof(Style)).Serialize(stream, this);}
}
}