mirror of
https://github.com/simtactics/mysimulation.git
synced 2025-03-15 14:51:21 +00:00
- NioTSO client isn't needed because we're using RayLib - Added FreeSO's API server to handle most backend operations
47 lines
1.1 KiB
C#
Executable file
47 lines
1.1 KiB
C#
Executable file
using System;
|
|
using System.Collections.Generic;
|
|
using System.Xml;
|
|
|
|
namespace FSO.Common.Utils
|
|
{
|
|
public class XMLList<T> : List<T>, IXMLEntity where T : IXMLEntity
|
|
{
|
|
private string NodeName;
|
|
|
|
public XMLList(string nodeName)
|
|
{
|
|
this.NodeName = nodeName;
|
|
}
|
|
|
|
public XMLList()
|
|
{
|
|
this.NodeName = "Unknown";
|
|
}
|
|
|
|
#region IXMLPrinter Members
|
|
|
|
public System.Xml.XmlElement Serialize(System.Xml.XmlDocument doc)
|
|
{
|
|
var element = doc.CreateElement(NodeName);
|
|
foreach (var child in this)
|
|
{
|
|
element.AppendChild(child.Serialize(doc));
|
|
}
|
|
return element;
|
|
}
|
|
|
|
public void Parse(System.Xml.XmlElement element)
|
|
{
|
|
var type = typeof(T);
|
|
|
|
foreach (XmlElement child in element.ChildNodes)
|
|
{
|
|
var instance = (T)Activator.CreateInstance(type);
|
|
instance.Parse(child);
|
|
this.Add(instance);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|