private void Compile(string expression, ExpressionOptions options) { // Add the services that will be used by elements during the compile IServiceContainer services = new ServiceContainer(); this.AddServices(services); // Parse and get the root element of the parse tree ExpressionElement topElement = MyContext.Parse(expression, services); if (options.ResultType == null) { options.ResultType = topElement.ResultType; } RootExpressionElement rootElement = new RootExpressionElement(topElement, options.ResultType); DynamicMethod dm = this.CreateDynamicMethod(); FleeILGenerator ilg = new FleeILGenerator(dm.GetILGenerator(), 0, false); // Emit the IL rootElement.Emit(ilg, services); ilg.ValidateLength(); // Emit to an assembly if required if (options.EmitToAssembly == true) { EmitToAssembly(rootElement, services); } Type delegateType = typeof(ExpressionEvaluator <>).MakeGenericType(typeof(T)); MyEvaluator = dm.CreateDelegate(delegateType) as ExpressionEvaluator <T>; }