mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-16 08:52:50 +08:00

Also moves tests to `./test` which makes it possible for all test projects to share the same .editorconfig files and similar.
39 lines
1.0 KiB
C#
39 lines
1.0 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Reflection;
|
|
|
|
namespace Spectre.Console.Tests
|
|
{
|
|
public static class EmbeddedResourceReader
|
|
{
|
|
public static Stream LoadResourceStream(string resourceName)
|
|
{
|
|
if (resourceName is null)
|
|
{
|
|
throw new ArgumentNullException(nameof(resourceName));
|
|
}
|
|
|
|
var assembly = Assembly.GetCallingAssembly();
|
|
resourceName = resourceName.Replace("/", ".");
|
|
|
|
return assembly.GetManifestResourceStream(resourceName);
|
|
}
|
|
|
|
public static Stream LoadResourceStream(Assembly assembly, string resourceName)
|
|
{
|
|
if (assembly is null)
|
|
{
|
|
throw new ArgumentNullException(nameof(assembly));
|
|
}
|
|
|
|
if (resourceName is null)
|
|
{
|
|
throw new ArgumentNullException(nameof(resourceName));
|
|
}
|
|
|
|
resourceName = resourceName.Replace("/", ".");
|
|
return assembly.GetManifestResourceStream(resourceName);
|
|
}
|
|
}
|
|
}
|