Dynamic invoke of a method using named parameters

后端 未结 3 990
耶瑟儿~
耶瑟儿~ 2020-12-16 07:41

We\'re currently using .NET 3.5 and part of our application uses dynamic invocation (using MethodBase.Invoke)

I am wondering if it is possible to mix in Named Parame

3条回答
  •  遥遥无期
    2020-12-16 08:06

    With .net4, I have an opensource framework ImpromptuInterface (found in nuget) that makes it easy to use the DLR apis for late invocation including named/optional parameters.

    var result = Impromptu.InvokeMember(target, "MyMethod", parameters.Select(pair=>  InvokeArg.Create(pair.Key, pair.Value)).Cast().ToArray());
    
        

    提交回复
    热议问题