Last active
August 29, 2015 13:59
-
-
Save davidwhitney/10744710 to your computer and use it in GitHub Desktop.
LOLWUT Dynamic expressions!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SomeType | |
{ | |
public string Name { get; set; } | |
} | |
const string body = "(MyThing.Name == \"Awesome\")"; | |
var p = Expression.Parameter(typeof (SomeType), "MyThing"); | |
var e = DynamicExpression.ParseLambda(new[] {p}, null, body); | |
var typeHere = new SomeType { Name = "Awesome" }; | |
var output = e.Compile().DynamicInvoke(typeHere); | |
Assert.That(output, Is.True); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment