Elin Decompiled Documentation EA 23.343.5 Nightly
Loading...
Searching...
No Matches
ModXml Class Reference

Static Public Member Functions

static string ValidXml (string name)
 
static string Text (XElement e)
 
static string[] SplitTags (string value)
 
static void ReadIdRow (XElement e, ref List< string[]> rows, string path)
 
static XDocument Load (byte[] bytes, out string error)
 

Static Private Member Functions

static string Attribute (XElement e, string name)
 

Static Private Attributes

static readonly string[] _validXml
 

Detailed Description

Definition at line 9 of file ModXml.cs.

Member Function Documentation

◆ Attribute()

static string ModXml.Attribute ( XElement  e,
string  name 
)
inlinestaticprivate

Definition at line 92 of file ModXml.cs.

93 {
94 return e.Attributes().FirstOrDefault((XAttribute a) => string.Equals(a.Name.LocalName, name, StringComparison.OrdinalIgnoreCase))?.Value;
95 }

Referenced by ReadIdRow().

◆ Load()

static XDocument ModXml.Load ( byte[]  bytes,
out string  error 
)
inlinestatic

Definition at line 97 of file ModXml.cs.

98 {
99 error = null;
100 XmlReaderSettings settings = new XmlReaderSettings
101 {
102 IgnoreComments = true,
103 IgnoreWhitespace = true,
104 IgnoreProcessingInstructions = true,
105 DtdProcessing = DtdProcessing.Prohibit,
106 XmlResolver = null
107 };
108 try
109 {
110 using MemoryStream input = new MemoryStream(bytes, writable: false);
111 using XmlReader reader = XmlReader.Create(input, settings);
112 return XDocument.Load(reader);
113 }
114 catch (Exception ex)
115 {
116 error = ex.Message;
117 return null;
118 }
119 }

Referenced by BaseModPackage.UpdateMeta().

◆ ReadIdRow()

static void ModXml.ReadIdRow ( XElement  e,
ref List< string[]>  rows,
string  path 
)
inlinestatic

Definition at line 50 of file ModXml.cs.

51 {
52 try
53 {
54 string text = Attribute(e, "id");
55 if (text.IsEmpty())
56 {
57 Debug.LogWarning("#mod package.xml <" + e.Name.LocalName + "> missing id, ignored: " + path);
58 return;
59 }
60 List<string> list = null;
61 string[] array = text.Split(',');
62 for (int i = 0; i < array.Length; i++)
63 {
64 string text2 = BaseModPackage.NormalizeId(array[i]);
65 if (!text2.IsEmpty())
66 {
67 if (list == null)
68 {
69 list = new List<string>();
70 }
71 if (!list.Contains(text2))
72 {
73 list.Add(text2);
74 }
75 }
76 }
77 if (list != null)
78 {
79 if (rows == null)
80 {
81 rows = new List<string[]>();
82 }
83 rows.Add(list.ToArray());
84 }
85 }
86 catch (Exception arg)
87 {
88 Debug.LogWarning($"#mod package.xml <{e.Name.LocalName}> is ill-formatted, ignored: {path}\n{arg}");
89 }
90 }
static string NormalizeId(string s)
static string Attribute(XElement e, string name)
Definition: ModXml.cs:92

References $, Attribute(), Debug, and BaseModPackage.NormalizeId().

Referenced by BaseModPackage.UpdateMeta().

◆ SplitTags()

static string[] ModXml.SplitTags ( string  value)
inlinestatic

Definition at line 27 of file ModXml.cs.

28 {
29 if (value.IsEmpty())
30 {
31 return null;
32 }
33 List<string> list = new List<string>();
34 string[] array = value.Split(',');
35 for (int i = 0; i < array.Length; i++)
36 {
37 string text = array[i].Trim();
38 if (!text.IsEmpty() && !list.Contains(text))
39 {
40 list.Add(text);
41 }
42 }
43 if (list.Count != 0)
44 {
45 return list.ToArray();
46 }
47 return null;
48 }

Referenced by BaseModPackage.UpdateMeta().

◆ Text()

static string ModXml.Text ( XElement  e)
inlinestatic

Definition at line 22 of file ModXml.cs.

23 {
24 return e.Value.Trim();
25 }

Referenced by BaseModPackage.UpdateMeta().

◆ ValidXml()

static string ModXml.ValidXml ( string  name)
inlinestatic

Definition at line 17 of file ModXml.cs.

18 {
19 return _validXml.FirstOrDefault((string known) => string.Equals(name, known, StringComparison.OrdinalIgnoreCase));
20 }
static readonly string[] _validXml
Definition: ModXml.cs:11

References _validXml.

Referenced by BaseModPackage.UpdateMeta().

Member Data Documentation

◆ _validXml

readonly string [] ModXml._validXml
staticprivate
Initial value:
= new string[14]
{
"title", "author", "id", "description", "version", "builtin", "tag", "tags", "loadPriority", "visibility",
"dependency", "incompatible", "loadAfter", "loadBefore"
}

Definition at line 11 of file ModXml.cs.

Referenced by ValidXml().


The documentation for this class was generated from the following file: