Creating delegates dynamically with parameter names

后端 未结 3 1421
Happy的楠姐
Happy的楠姐 2020-12-06 02:55

Hi I\'m trying to create a function that dynamically creates a delegate with the same return value and the same parameters as a MethodInfo it receives as parameter and also

3条回答
  •  臣服心动
    2020-12-06 03:32

    The open source framework ImpromptuInterface (v5.6.7 via nuget) has a DLR currying/partial apply implementation that I think would work in this case as long as you don't need a literal delegate.

    Here is the c# version of creating it and invoking it:

    dynamic jump =Impromptu.Curry(adam).Jump();
    jump(cheer:"yay", height:(uint)3);
    

    So jump isn't a literal delegate, you cannot reflect it, but you can invoke it directly as if it were a delegate and it's a DLR object so my guess is that it would work just the same in python.

提交回复
热议问题