Permalink
Browse files

compile rule calls by default

  • Loading branch information...
1 parent 6df2be3 commit fb7870b19e31ed8ea66d2e25a5a3262d7dba22ad @pragmatrix committed Apr 27, 2012
Showing with 2 additions and 4 deletions.
  1. +2 −4 Rulez/RuleSet.cs
View
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
+using System.Linq;
+using System.Linq.Expressions;
using System.Reflection;
namespace Rulez
@@ -31,13 +33,9 @@ void addMethod(Func<Type, object> resolver_, MethodInfo method)
for (int i = 0; i != parameters.Length; ++i)
args[i] = resolver_(parameters[i].ParameterType);
-#if !COMPILEIT
- addRule(() => method.Invoke(this, args));
-#else
var parameterExpressions = args.Select(Expression.Constant);
var call = Expression.Call(Expression.Constant(this), method, parameterExpressions);
addRule(Expression.Lambda<Action>(call).Compile());
-#endif
}
public void Dispose()

0 comments on commit fb7870b

Please sign in to comment.