mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 21:38:16 +08:00

committed by
Patrik Svensson

parent
bde61cc6ff
commit
a59e0dcb21
32
src/Spectre.Console/Internal/ResourceReader.cs
Normal file
32
src/Spectre.Console/Internal/ResourceReader.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Spectre.Console.Internal
|
||||
{
|
||||
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().NormalizeLineEndings();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user