Is there an easy way to parse a (lambda expression) string into an Action delegate?

前端 未结 4 522
谎友^
谎友^ 2020-12-05 11:18

I have a method that alters an \"Account\" object based on the action delegate passed into it:

public static void AlterAccount(string AccountID, Action

        
4条回答
  •  悲哀的现实
    2020-12-05 12:17

    You may try this: Dynamic Lambda Expressions Using An Isolated AppDomain

    It compiles a lambda expression using CodeDOM compiler. In order to dispose the in-memory assembly that gets created, the compiler runs on an isolated AppDomain. For the passing the expression through the domain boundary, it has to be serialized. Alas, Expression<> is not Serializable. So, a trick has to be used. All the details are explained in the post.

    I'm the author of that component, by the way. I would like very much to hear your feedback from it.

提交回复
热议问题