switch root namespace name to NITLOAD

This commit is contained in:
Youmu Liu
2026-09-02 18:15:03 +08:00
parent 4218baad48
commit 7c7101ee48
502 changed files with 710 additions and 721 deletions
@@ -0,0 +1,20 @@
// -----------------------------------------------------------------------------
// file="XmlTreeDocument"
// Project: StgSharp
// Copyright (c) Nitload.
// SPDX-License-Identifier: MIT
// -----------------------------------------------------------------------------
using System.Xml.Linq;
namespace StgSharp.GenerateGL.Tree
{
/// <summary>
/// Holds the original XML text alongside its parsed tree.
/// </summary>
internal sealed record XmlTreeDocument(
string SourcePath,
string SourceText,
XDocument Tree
);
}
@@ -0,0 +1,56 @@
// -----------------------------------------------------------------------------
// file="XmlTreeReader"
// Project: StgSharp
// Copyright (c) Nitload.
// SPDX-License-Identifier: MIT
// -----------------------------------------------------------------------------
using System;
using System.IO;
using System.Xml;
using System.Xml.Linq;
namespace StgSharp.GenerateGL.Tree
{
/// <summary>
/// Loads XML as a generic tree without interpreting OpenGL semantics.
/// </summary>
internal static class XmlTreeReader
{
public static XmlTreeDocument Load(
string path
)
{
ArgumentException.ThrowIfNullOrWhiteSpace(path);
string sourcePath = Path.GetFullPath(path);
string sourceText = File.ReadAllText(sourcePath);
XmlReaderSettings settings = new XmlReaderSettings
{
DtdProcessing = DtdProcessing.Prohibit,
IgnoreComments = false,
IgnoreWhitespace = false,
XmlResolver = null,
};
XDocument tree;
using (StringReader textReader = new StringReader(sourceText))
using (XmlReader reader = XmlReader.Create(textReader, settings, sourcePath))
{
tree = XDocument.Load(
reader,
LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo);
}
if (tree.Root is null)
{
throw new InvalidDataException(
$"XML document '{sourcePath}' does not contain a root element.");
}
return new XmlTreeDocument(sourcePath, sourceText, tree);
}
}
}