mirror of
https://github.com/simtactics/mysimulation.git
synced 2025-07-07 15:10:27 -04:00
Removed NioTSO client and server
- NioTSO client isn't needed because we're using RayLib - Added FreeSO's API server to handle most backend operations
This commit is contained in:
parent
f12ba1502b
commit
22191ce648
591 changed files with 53264 additions and 3362 deletions
43
server/tso.common/Utils/IXMLEntity.cs
Executable file
43
server/tso.common/Utils/IXMLEntity.cs
Executable file
|
@ -0,0 +1,43 @@
|
|||
using System;
|
||||
using System.Xml;
|
||||
|
||||
namespace FSO.Common.Utils
|
||||
{
|
||||
public interface IXMLEntity
|
||||
{
|
||||
XmlElement Serialize(XmlDocument doc);
|
||||
void Parse(XmlElement element);
|
||||
}
|
||||
|
||||
public static class XMLUtils
|
||||
{
|
||||
public static T Parse<T>(string data) where T : IXMLEntity
|
||||
{
|
||||
var doc = new XmlDocument();
|
||||
doc.LoadXml(data);
|
||||
|
||||
T result = (T)Activator.CreateInstance(typeof(T));
|
||||
result.Parse((XmlElement)doc.FirstChild);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void AppendTextNode(this XmlElement e, string nodeName, string value)
|
||||
{
|
||||
var node = e.OwnerDocument.CreateElement(nodeName);
|
||||
node.AppendChild(e.OwnerDocument.CreateTextNode(value));
|
||||
e.AppendChild(node);
|
||||
}
|
||||
|
||||
public static string ReadTextNode(this XmlElement e, string nodeName)
|
||||
{
|
||||
foreach (XmlElement child in e.ChildNodes)
|
||||
{
|
||||
if (child.Name == nodeName && child.FirstChild != null)
|
||||
{
|
||||
return child.FirstChild?.Value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue