#if REFLECTION_EMIT_COMPILER using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; namespace FastReport.Code.Expressions { public abstract class ILParser { private static readonly ConcurrentDictionary _cache = new ConcurrentDictionary(); public static ILParser Create(Report report) { return new CSharpILParser(report); } private static object Invoke(MethodInfo method, object[] args) { var result = method.Invoke(null, args); //Debug.WriteLine(result); return result; } public object StartDynamic(string expression, Report report, Variant value) { if (!_cache.TryGetValue(expression, out var compiledExpression)) { Debug.WriteLine($"Compilation: {expression}"); compiledExpression = CompileExpression(expression, new[] {report.GetType(), value.GetType()}); _cache.TryAdd(expression, compiledExpression); } return Invoke(compiledExpression, new object[] { report, value }); } protected abstract MethodInfo CompileExpression(string expression, Type[] argTypes); } } #endif