Esempio n. 1
0
        public static EmitSyntax LdMethodDelegate(
            this EmitSyntax emit,
            Ref <Types> declaringType,
            string methodName,
            Type delegateType)
        {
            var method = delegateType.GetMethod("Invoke");
            Pipe <WantArgsSigBase> argBuilder =
                args =>
            {
                foreach (var param in method.GetParameters())
                {
                    var argType = emit.Types.Import(param.ParameterType);
                    args = args.Argument(argType, param.Name);
                }

                return(args);
            };

            return(emit.LdMethodDelegate(
                       scope =>
            {
                return scope.StartSignature
                .Returning(emit.Types.Import(method.ReturnType))
                .DecaringType(declaringType)
                .Named(methodName)
                .BeginArgs()
                .Do(argBuilder)
                .EndArgs()
                ;
            },
                       delegateType));
        }