public static void EnsureInitialized(Assembly fsharpCoreAssembly) { if (!FSharpUtils._initialized) { lock (FSharpUtils.Lock) { if (!FSharpUtils._initialized) { FSharpUtils.FSharpCoreAssembly = fsharpCoreAssembly; Type type = fsharpCoreAssembly.GetType("Microsoft.FSharp.Reflection.FSharpType"); MethodInfo methodWithNonPublicFallback = FSharpUtils.GetMethodWithNonPublicFallback(type, "IsUnion", BindingFlags.Static | BindingFlags.Public); FSharpUtils.IsUnion = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall <object>(methodWithNonPublicFallback); MethodInfo methodInfo = FSharpUtils.GetMethodWithNonPublicFallback(type, "GetUnionCases", BindingFlags.Static | BindingFlags.Public); FSharpUtils.GetUnionCases = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall <object>(methodInfo); Type type1 = fsharpCoreAssembly.GetType("Microsoft.FSharp.Reflection.FSharpValue"); FSharpUtils.PreComputeUnionTagReader = FSharpUtils.CreateFSharpFuncCall(type1, "PreComputeUnionTagReader"); FSharpUtils.PreComputeUnionReader = FSharpUtils.CreateFSharpFuncCall(type1, "PreComputeUnionReader"); FSharpUtils.PreComputeUnionConstructor = FSharpUtils.CreateFSharpFuncCall(type1, "PreComputeUnionConstructor"); Type type2 = fsharpCoreAssembly.GetType("Microsoft.FSharp.Reflection.UnionCaseInfo"); FSharpUtils.GetUnionCaseInfoName = JsonTypeReflector.ReflectionDelegateFactory.CreateGet <object>(type2.GetProperty("Name")); FSharpUtils.GetUnionCaseInfoTag = JsonTypeReflector.ReflectionDelegateFactory.CreateGet <object>(type2.GetProperty("Tag")); FSharpUtils.GetUnionCaseInfoDeclaringType = JsonTypeReflector.ReflectionDelegateFactory.CreateGet <object>(type2.GetProperty("DeclaringType")); FSharpUtils.GetUnionCaseInfoFields = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall <object>(type2.GetMethod("GetFields")); FSharpUtils._ofSeq = fsharpCoreAssembly.GetType("Microsoft.FSharp.Collections.ListModule").GetMethod("OfSeq"); FSharpUtils._mapType = fsharpCoreAssembly.GetType("Microsoft.FSharp.Collections.FSharpMap`2"); Thread.MemoryBarrier(); FSharpUtils._initialized = true; } } } }
// Token: 0x06000DAB RID: 3499 RVA: 0x0004FC50 File Offset: 0x0004DE50 private FSharpUtils(Assembly fsharpCoreAssembly) { this.FSharpCoreAssembly = fsharpCoreAssembly; Type type = fsharpCoreAssembly.GetType("Microsoft.FSharp.Reflection.FSharpType"); MethodInfo methodWithNonPublicFallback = FSharpUtils.GetMethodWithNonPublicFallback(type, "IsUnion", BindingFlags.Static | BindingFlags.Public); this.IsUnion = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall <object>(methodWithNonPublicFallback); MethodInfo methodWithNonPublicFallback2 = FSharpUtils.GetMethodWithNonPublicFallback(type, "GetUnionCases", BindingFlags.Static | BindingFlags.Public); this.GetUnionCases = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall <object>(methodWithNonPublicFallback2); Type type2 = fsharpCoreAssembly.GetType("Microsoft.FSharp.Reflection.FSharpValue"); this.PreComputeUnionTagReader = FSharpUtils.CreateFSharpFuncCall(type2, "PreComputeUnionTagReader"); this.PreComputeUnionReader = FSharpUtils.CreateFSharpFuncCall(type2, "PreComputeUnionReader"); this.PreComputeUnionConstructor = FSharpUtils.CreateFSharpFuncCall(type2, "PreComputeUnionConstructor"); Type type3 = fsharpCoreAssembly.GetType("Microsoft.FSharp.Reflection.UnionCaseInfo"); this.GetUnionCaseInfoName = JsonTypeReflector.ReflectionDelegateFactory.CreateGet <object>(type3.GetProperty("Name")); this.GetUnionCaseInfoTag = JsonTypeReflector.ReflectionDelegateFactory.CreateGet <object>(type3.GetProperty("Tag")); this.GetUnionCaseInfoDeclaringType = JsonTypeReflector.ReflectionDelegateFactory.CreateGet <object>(type3.GetProperty("DeclaringType")); this.GetUnionCaseInfoFields = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall <object>(type3.GetMethod("GetFields")); Type type4 = fsharpCoreAssembly.GetType("Microsoft.FSharp.Collections.ListModule"); this._ofSeq = type4.GetMethod("OfSeq"); this._mapType = fsharpCoreAssembly.GetType("Microsoft.FSharp.Collections.FSharpMap`2"); }
private static MethodCall <object, object> CreateFSharpFuncCall(Type type, string methodName) { MethodInfo methodWithNonPublicFallback = FSharpUtils.GetMethodWithNonPublicFallback(type, methodName, BindingFlags.Static | BindingFlags.Public); MethodInfo method = methodWithNonPublicFallback.ReturnType.GetMethod("Invoke", BindingFlags.Instance | BindingFlags.Public); MethodCall <object, object> methodCall = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall <object>(methodWithNonPublicFallback); MethodCall <object, object> methodCall1 = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall <object>(method); return((object target, object[] args) => new FSharpFunction(methodCall(target, args), methodCall1)); }
private static MethodCall <object, object> CreateFSharpFuncCall(Type type, string methodName) { MethodInfo methodWithNonPublicFallback = FSharpUtils.GetMethodWithNonPublicFallback(type, methodName, BindingFlags.Static | BindingFlags.Public); MethodInfo method = methodWithNonPublicFallback.ReturnType.GetMethod("Invoke", BindingFlags.Instance | BindingFlags.Public); MethodCall <object, object> call = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall <object>(methodWithNonPublicFallback); MethodCall <object, object> invoke = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall <object>(method); return(([Nullable(2)] object target, [Nullable(new byte[]