39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Resources;
|
|
using System.Text;
|
|
|
|
namespace Plane.Reflection
|
|
{
|
|
public static class Utils
|
|
{
|
|
public static Dictionary<string, Stream> GetResourcesUnder(string dir)
|
|
{
|
|
dir = dir.ToLower();
|
|
if (!dir.EndsWith("/"))
|
|
{
|
|
dir += "/";
|
|
}
|
|
|
|
var assembly = Assembly.GetCallingAssembly();
|
|
var resourcesName = assembly.GetName().Name + ".g.resources";
|
|
var stream = assembly.GetManifestResourceStream(resourcesName);
|
|
var resourceReader = new ResourceReader(stream);
|
|
|
|
return
|
|
(from p in resourceReader.OfType<DictionaryEntry>()
|
|
let theme = (string)p.Key
|
|
where theme.StartsWith(dir)
|
|
select new
|
|
{
|
|
Key = theme.Substring(dir.Length),
|
|
Value = p.Value as Stream
|
|
}).ToDictionary(i => i.Key, i => i.Value);
|
|
}
|
|
}
|
|
}
|