static void buildManagedDelegates(Type tInterface, IEnumerable <CustomMarshallerMethod> enumMethods) { CustomMarshallerMethod[] methods = enumMethods.ToArray(); if (methods.Length <= 0) { return; } DelegatesBuilder tbDelegates = new DelegatesBuilder(tInterface.FullName + "_custom"); foreach (var m in methods) { m.emitManagedDelegate(tbDelegates); } tbDelegates.createType(); }
/// <summary>Build static class with the native function pointer delegates, return array of delegate types. /// It caches the results because the delegate types are used for both directions of the interop.</summary> public static Type[] buildDelegates(Type tInterface) { lock ( syncRoot ) { Type[] result; if (delegatesCache.TryGetValue(tInterface, out result)) { return(result); } var tbDelegates = new DelegatesBuilder(tInterface.FullName + "_native"); // Add delegate types per method result = tInterface.getMethodsWithoutProperties().Select(mi => createDelegate(tbDelegates, mi)).ToArray(); tbDelegates.createType(); delegatesCache.Add(tInterface, result); return(result); } }