Files
Il2CppInspectorRedux/Il2CppInspector.Common/ResourceHelper.cs
Katy Coe deeb8daa97 Unity/C++: Significant re-factoring of Unity header management (see description)
Extract resource handling to UnityResource
Add API header resource helpers
Fix UnityVersion ToString() when Min == Max
Replace fixed list of Il2Cpp header reserved names with parsed names from actual selected headers (solves TypeInfo/MemberInfo problems in 5.3.0-5.3.4 (metadata v16-20))
Use CppDeclarationGenerator when initializing CppTypeCollection to ensure all Il2Cpp header symbols are reserved
Process API headers in CppTypeCollection.FromUnityHeaders
Move #define IS_32BIT handling to UnityHeaders
Update tests
2020-07-22 19:01:33 +02:00

37 lines
1.1 KiB
C#

/*
Copyright 2017-2020 Katy Coe - http://www.djkaty.com - https://github.com/djkaty
Copyright 2020 Robert Xiao - https://robertxiao.ca
All rights reserved.
*/
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
namespace Il2CppInspector
{
internal static class ResourceHelper
{
// Get a string resource
public static string GetText(string resourceName) {
Assembly assembly = Assembly.GetCallingAssembly();
using Stream stream = assembly.GetManifestResourceStream(resourceName);
if (stream == null) {
throw new FileNotFoundException(resourceName);
}
using StreamReader reader = new StreamReader(stream);
string result = reader.ReadToEnd();
return result;
}
// Get a list of resources for a namespace
public static IEnumerable<string> GetNamesForNamespace(string ns) {
Assembly assembly = Assembly.GetExecutingAssembly();
return assembly.GetManifestResourceNames().Where(s => s.StartsWith(ns + "."));
}
}
}