MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Factory

Method Factory

Source/Engine/Engine/NativeInterop.cs:357–367  ·  view source on GitHub ↗
(Type type)

Source from the content-addressed store, hash-verified

355 internal static object MarshalToManaged(IntPtr nativePtr, Type type)
356 {
357 static MarshalToManagedDelegate Factory(Type type)
358 {
359 Type marshalType = type;
360 if (marshalType.IsByRef)
361 marshalType = marshalType.GetElementType();
362 else if (marshalType.IsPointer)
363 marshalType = typeof(IntPtr);
364
365 MethodInfo method = typeof(MarshalHelper<>).MakeGenericType(marshalType).GetMethod(nameof(MarshalHelper<ReferenceTypePlaceholder>.ToManagedWrapper), BindingFlags.Static | BindingFlags.NonPublic);
366 return method.CreateDelegate<MarshalToManagedDelegate>();
367 }
368
369 if (!toManagedMarshallers.TryGetValue(type, out var deleg))
370 deleg = toManagedMarshallers.GetOrAdd(type, Factory);

Callers

nothing calls this directly

Calls 3

MakeGenericTypeMethod · 0.80
GetElementTypeMethod · 0.45
GetMethodMethod · 0.45

Tested by

no test coverage detected