protected virtual Type GetHostType() { if (BaseType?.Name == "MulticastDelegate") { var invokeMethodDef = TypeDefinition.Methods.FirstOrDefault(_ => _.Name == "Invoke"); if (invokeMethodDef != null) { return(ScriptDelegate.GetDelegateType(invokeMethodDef.Parameters.Count)); } } return(BaseType?.HostType); }
protected override MethodBase GetNativeMethod(Type[] types) { MethodInfo nativeMethod; if (!_nativeMethods.TryGetValue(MethodDefinition.MetadataToken.ToInt32(), out nativeMethod)) { if (DeclareType.IsDelegate) { nativeMethod = ScriptDelegate.GetDelegateType(types.Length).GetMethod("Invoke"); } } if (nativeMethod.ContainsGenericParameters) { nativeMethod = nativeMethod.MakeGenericMethod(_genericTypes.Select(_ => _.HostType).ToArray()); } return(nativeMethod); }