c# - Displaying FQN in Expression.Call -
I'm trying to represent the string of Static method calls that I've created using Expression Tree. However, FQN is not a literal representation in text representation. TestMethod () output code instead of AnotherClass.TestMethod () Edit: This is just a simple example Eventually the output can be something like this: - Therefore, I'm not just trying to get the FQN of a method, the original expression object may not even call a method I thought Was that the expression is too complicated, no toasting will return the C # code which it can represent The goal is to convert the original expression into the C # code snippet, which I used to remember in memory I can use and compile. if (recently edited in your queue ) You want to turn some expression into executable, you can do something instead: You can call the compiled expression because you have another action
Other class. Test method method & gt; Guid & gt; ("BLOB_DATA", New MyClass ())
using the system; Using System.Linq.Expressions; Using the system. Namespace Expression Test {Private Static Zero Main (string [] Args) {// Version 1 Dyslexation Call = Expression Call (type off (other class), "testmanth", type elite type); Console.WriteLine (call.ToString ()); // version 2 methodInfo method = type (other class). GetMethi ("Testmith"); MethodCallExpressionCall2 = Expression. Call (method); Console.WriteLine (call2.ToString ()); Console.ReadLine (); }} Internal category other class {public static zero} TestMethod () {}}}
string.format ("{0}. {1}", type the disclaimer .name, method .name)
action compiled = expression Lambda & lt; Action & gt; (Call 2). Compile ();
Comments
Post a Comment