mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 13:28:16 +08:00
33 lines
914 B
C#
33 lines
914 B
C#
using System;
|
|
using System.IO;
|
|
|
|
namespace Spectre.Console
|
|
{
|
|
internal static class ResourceReader
|
|
{
|
|
public static string ReadManifestData(string resourceName)
|
|
{
|
|
if (resourceName is null)
|
|
{
|
|
throw new ArgumentNullException(nameof(resourceName));
|
|
}
|
|
|
|
var assembly = typeof(ResourceReader).Assembly;
|
|
resourceName = resourceName.ReplaceExact("/", ".");
|
|
|
|
using (var stream = assembly.GetManifestResourceStream(resourceName))
|
|
{
|
|
if (stream == null)
|
|
{
|
|
throw new InvalidOperationException("Could not load manifest resource stream.");
|
|
}
|
|
|
|
using (var reader = new StreamReader(stream))
|
|
{
|
|
return reader.ReadToEnd().NormalizeNewLines();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|