28 lines
852 B
C#
28 lines
852 B
C#
using System.Reflection;
|
|
|
|
namespace StellaOps.Evidence.Validation;
|
|
|
|
internal static class SchemaLoader
|
|
{
|
|
public static string LoadSchema(string fileName)
|
|
{
|
|
var assembly = Assembly.GetExecutingAssembly();
|
|
var resourceName = assembly.GetManifestResourceNames()
|
|
.FirstOrDefault(name => name.EndsWith(fileName, StringComparison.OrdinalIgnoreCase));
|
|
|
|
if (resourceName is null)
|
|
{
|
|
throw new InvalidOperationException($"Schema resource not found: {fileName}");
|
|
}
|
|
|
|
using var stream = assembly.GetManifestResourceStream(resourceName);
|
|
if (stream is null)
|
|
{
|
|
throw new InvalidOperationException($"Schema resource not available: {resourceName}");
|
|
}
|
|
|
|
using var reader = new StreamReader(stream);
|
|
return reader.ReadToEnd();
|
|
}
|
|
}
|