Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }