mirror of
				https://github.com/nsnail/spectre.console.git
				synced 2025-10-31 09:09:25 +08:00 
			
		
		
		
	 c9b178ac96
			
		
	
	c9b178ac96
	
	
	
		
			
			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);
 | |
|         }
 | |
|     }
 | |
| }
 |