Beispiel #1
0
    public static void SaveConfig <V>(List <V> x, string file) where V : EXml
    {
        StringWriter stringWriter = new StringWriter();

        EXml.Write <V>(stringWriter, "Root", x);
        File.WriteAllText(file, stringWriter.ToString());
    }
Beispiel #2
0
    public void Save(string file)
    {
        StringWriter stringWriter = new StringWriter();

        EXml.Write(stringWriter, "Root", this);
        File.WriteAllText(file, stringWriter.ToString());
    }
Beispiel #3
0
 public static void Write <V>(TextWriter os, string name, HashSet <V> x)
 {
     os.WriteLine("<{0}>", name);
     foreach (V current in x)
     {
         EXml.Write(os, NODENAME, current);
     }
     os.WriteLine("</{0}>", name);
 }
Beispiel #4
0
 public static void Write(TextWriter os, string name, EXml x)
 {
     if (x == null)
     {
         return;
     }
     os.WriteLine("<{0} Type=\"{1}\">", name, x.GetType().Name);
     x.Write(os);
     os.WriteLine("</{0}>", name);
 }
Beispiel #5
0
 public static void Write(TextWriter os, string name, object x)
 {
     if (x == null)
     {
         return;
     }
     if (x is bool)
     {
         EXml.Write(os, name, (bool)x);
     }
     else
     {
         if (x is int)
         {
             EXml.Write(os, name, (int)x);
         }
         else
         {
             if (x is long)
             {
                 EXml.Write(os, name, (long)x);
             }
             else
             {
                 if (x is float)
                 {
                     EXml.Write(os, name, (float)x);
                 }
                 else
                 {
                     if (x is string)
                     {
                         EXml.Write(os, name, (string)x);
                     }
                     else
                     {
                         if (x is Vector3)
                         {
                             EXml.Write(os, name, (Vector3)x);
                         }
                         else
                         {
                             if (!(x is EXml))
                             {
                                 throw new Exception("unknown marshal type;" + x.GetType());
                             }
                             EXml.Write(os, name, (EXml)x);
                         }
                     }
                 }
             }
         }
     }
 }
Beispiel #6
0
 public static void Write <V>(TextWriter os, string name, List <V> x)
 {
     if (x.Count == 0)
     {
         return;
     }
     os.WriteLine("<{0}>", name);
     x.ForEach(delegate(V v)
     {
         EXml.Write(os, NODENAME, v);
     });
     os.WriteLine("</{0}>", name);
 }
Beispiel #7
0
    public static void Write <K, V>(TextWriter os, KeyValuePair <K, V> x)
    {
        string key = x.Key.ToString();

        if (x.Value is EXml)
        {
            EXml   v     = x.Value as EXml;
            string pName = x.GetType().Name;
            os.WriteLine("<{0}  {1}=\"{2}\">", pName, KEYNAME, key);
            v.Write(os);
            os.WriteLine("</{0}>", pName);
        }
        else
        {
            os.WriteLine("<{0}  {1}=\"{2}\">{3}</{0}>", NODENAME, KEYNAME, key, x.Value);
        }
    }
Beispiel #8
0
 public static void WriteDynamicObject(TextWriter os, string name, EXml x)
 {
     os.WriteLine("<{0} {1}=\"{2}\">", name, TYPENAME, x.GetType().ToString());
     x.Write(os);
     os.WriteLine("</{0}>", name);
 }