|
@ -8,6 +8,7 @@ using System.Reflection.Emit; |
|
|
using System.Text; |
|
|
using System.Text; |
|
|
using System.Threading; |
|
|
using System.Threading; |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
|
|
|
using System.Linq.Expressions; |
|
|
#if NET3
|
|
|
#if NET3
|
|
|
using Net3_Proxy; |
|
|
using Net3_Proxy; |
|
|
using Array = Net3_Proxy.Array; |
|
|
using Array = Net3_Proxy.Array; |
|
@ -155,6 +156,8 @@ namespace IPA.Config.Stores |
|
|
|
|
|
|
|
|
var GetTypeFromHandle = typeof(Type).GetMethod(nameof(Type.GetTypeFromHandle)); |
|
|
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
|
|
|
#region Parse base object structure
|
|
|
var baseChanged = type.GetMethod("Changed", BindingFlags.Public | BindingFlags.Instance, null, Type.EmptyTypes, Array.Empty<ParameterModifier>()); |
|
|
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
|
|
|
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 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
|
|
|
{ // register a member map
|
|
|
var dict = new Dictionary<string, Type>(); |
|
|
var dict = new Dictionary<string, Type>(); |
|
|
foreach (var kvp in structure) |
|
|
foreach (var kvp in structure) |
|
@ -433,7 +441,7 @@ namespace IPA.Config.Stores |
|
|
memberMaps.Add(type, dict); |
|
|
memberMaps.Add(type, dict); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
|
return creatorDel; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// expects the this param to be on the stack
|
|
|
// expects the this param to be on the stack
|
|
|