Cosmos/source/Cosmos.IL2CPU/CustomImplementation/System/ObjectImplRefs.cs
2015-12-18 08:08:49 -06:00

40 lines
No EOL
1.3 KiB
C#

using System;
using System.Reflection;
namespace Cosmos.IL2CPU.CustomImplementation.System
{
public static class ObjectImplRefs
{
public static readonly MethodBase ObjectCtor;
public static readonly Assembly RuntimeAssemblyDef;
static ObjectImplRefs()
{
Type xType = typeof(object);
ObjectCtor = xType.GetMethod("Ctor", new Type[] { typeof(IntPtr) });
if (ObjectCtor == null)
{
throw new Exception("Implementation of ObjectCtor not found!");
}
xType = typeof(ObjectImpl);
foreach (FieldInfo xField in typeof(ObjectImplRefs).GetFields())
{
if (xField.Name.EndsWith("Ref"))
{
MethodBase xTempMethod = xType.GetMethod(
xField.Name.Substring(0, xField.Name.Length - "Ref".Length));
if (xTempMethod == null)
{
throw new Exception(
"Method '" + xField.Name.Substring(0, xField.Name.Length - "Ref".Length)
+ "' not found on RuntimeEngine!");
}
xField.SetValue(null, xTempMethod);
}
}
}
}
}