Browse Source

Added delegate creation to GeneratedStore

pull/46/head
Anairkoen Schno 5 years ago
parent
commit
c1e5057aa1
1 changed files with 9 additions and 1 deletions
  1. +9
    -1
      IPA.Loader/Config/Stores/GeneratedStore.cs

+ 9
- 1
IPA.Loader/Config/Stores/GeneratedStore.cs View File

@ -8,6 +8,7 @@ using System.Reflection.Emit;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Linq.Expressions;
#if NET3
using Net3_Proxy;
using Array = Net3_Proxy.Array;
@ -155,6 +156,8 @@ namespace IPA.Config.Stores
var GetTypeFromHandle = typeof(Type).GetMethod(nameof(Type.GetTypeFromHandle));
// TODO: possibly move all of this manual IL over to Linq.Expressions
#region Parse base object structure
var baseChanged = type.GetMethod("Changed", BindingFlags.Public | BindingFlags.Instance, null, Type.EmptyTypes, Array.Empty<ParameterModifier>());
if (baseChanged != null && !baseChanged.IsVirtual) baseChanged = null; // limit this to just the one thing
@ -426,6 +429,11 @@ namespace IPA.Config.Stores
var genType = typeBuilder.CreateType();
var parentParam = Expression.Parameter(typeof(IGeneratedStore), "parent");
var creatorDel = Expression.Lambda<Func<IGeneratedStore, IConfigStore>>(
Expression.New(ctor, parentParam), parentParam
).Compile();
{ // register a member map
var dict = new Dictionary<string, Type>();
foreach (var kvp in structure)
@ -433,7 +441,7 @@ namespace IPA.Config.Stores
memberMaps.Add(type, dict);
}
return null;
return creatorDel;
}
// expects the this param to be on the stack


Loading…
Cancel
Save