private void Compile() { if (DataContext == null) { throw ExceptionBuilder.PropertyNotInitialized("DataContext"); } if (Text == null || Text.Length == 0) { throw ExceptionBuilder.PropertyNotInitialized("Text"); } // Compile expression ClearCompiledState(); Compiler compiler = new Compiler(_errorCollector); ExpressionNode expressionNode = compiler.CompileExpression(Text, _targetType, Scope); if (_errorCollector.ErrorsSeen) { IList <CompilationError> errors = _errorCollector.GetErrors(); OnCompilationFailed(new CompilationFailedEventArgs(errors)); throw ExceptionBuilder.ExpressionCompilationFailed(errors); } OnCompilationSucceeded(EventArgs.Empty); _runtimeExpression = ExpressionCompiler.CreateCompiled(expressionNode); ILEmitContext.CompleteILCompilation(); }