Question about Source Code

Sep 4, 2010 at 6:39 PM


I have a question regarding certain lines your source code. When saving the level, you always deserialize the class which automatically generates a formatted XML file for easy use.

However, in Layer.Editor, you do something manual which I do not understand

                String s = sw.GetStringBuilder().ToString();
                s = s.Replace("  ", "    ");
                s = s.Remove(0, s.IndexOf(""));
                s = s.Replace("", "");
                s = s.Replace("\n", "\n                ");

                writer.WriteAttributeString("Name", i.Name);
                writer.WriteAttributeString("Visible", i.Visible.ToString());
                writer.WriteRaw(/*"\n" + */s.ToString()/* + "\n            "*/);
why is this necessary ?

Sep 6, 2010 at 8:29 AM
Edited Sep 6, 2010 at 8:45 AM

this code is from the method

public void WriteXml(XmlWriter writer)

in the file Layer.Editable.cs.

This method is part of the interface IXmlSerializable, which Layer once should implement (for some experiments) but I finally decided to refrain from that.

You can see that in line 15:

public partial class Layer //: IXmlSerializable


I just forgot to comment out (or remove) the implementation of the corresponding methods.

So, you can ignore (and remove) the methods

public System.Xml.Schema.XmlSchema GetSchema() 
public void ReadXml(XmlReader reader) 
public void WriteXml(XmlWriter writer) 

inside Layer.Editable.cs.

I will do that in the next revision.

So, to cut a long story short:

It is part of an experiment that I once did and can now be totally ignored since it is not called at all.