2using System.Collections.Generic;
11 private static readonly
string[]
_validXml =
new string[14]
13 "title",
"author",
"id",
"description",
"version",
"builtin",
"tag",
"tags",
"loadPriority",
"visibility",
14 "dependency",
"incompatible",
"loadAfter",
"loadBefore"
19 return _validXml.FirstOrDefault((
string known) =>
string.Equals(name, known, StringComparison.OrdinalIgnoreCase));
22 public static string Text(XElement e)
24 return e.Value.Trim();
33 List<string> list =
new List<string>();
34 string[] array = value.Split(
',');
35 for (
int i = 0; i < array.Length; i++)
37 string text = array[i].Trim();
38 if (!text.IsEmpty() && !list.Contains(text))
45 return list.ToArray();
50 public static void ReadIdRow(XElement e, ref List<
string[]> rows,
string path)
57 Debug.LogWarning(
"#mod package.xml <" + e.Name.LocalName +
"> missing id, ignored: " + path);
60 List<string> list =
null;
61 string[] array = text.Split(
',');
62 for (
int i = 0; i < array.Length; i++)
69 list =
new List<string>();
71 if (!list.Contains(text2))
81 rows =
new List<string[]>();
83 rows.Add(list.ToArray());
88 Debug.LogWarning(
$"#mod package.xml <{e.Name.LocalName}> is ill-formatted, ignored: {path}\n{arg}");
92 private static string Attribute(XElement e,
string name)
94 return e.Attributes().FirstOrDefault((XAttribute a) =>
string.Equals(a.Name.LocalName, name, StringComparison.OrdinalIgnoreCase))?.Value;
97 public static XDocument
Load(
byte[] bytes, out
string error)
100 XmlReaderSettings settings =
new XmlReaderSettings
102 IgnoreComments =
true,
103 IgnoreWhitespace =
true,
104 IgnoreProcessingInstructions =
true,
105 DtdProcessing = DtdProcessing.Prohibit,
110 using MemoryStream input =
new MemoryStream(bytes, writable:
false);
111 using XmlReader reader = XmlReader.Create(input, settings);
112 return XDocument.Load(reader);
static string NormalizeId(string s)
static XDocument Load(byte[] bytes, out string error)
static string Attribute(XElement e, string name)
static string[] SplitTags(string value)
static string ValidXml(string name)
static string Text(XElement e)
static void ReadIdRow(XElement e, ref List< string[]> rows, string path)
static readonly string[] _validXml