Пример #1
0
        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();
        }
Пример #2
0
        private void Compile()
        {
            if (DataContext == null)
            {
                throw ExceptionBuilder.PropertyNotInitialized("DataContext");
            }

            if (Text == null || Text.Length == 0)
            {
                throw ExceptionBuilder.PropertyNotInitialized("Text");
            }

            // Compile query

            ClearCompiledState();
            Compiler compiler = new Compiler(_errorCollector);

            _resultAlgebraNode = compiler.CompileQuery(Text, Scope);

            if (_errorCollector.ErrorsSeen)
            {
                IList <CompilationError> errors = _errorCollector.GetErrors();
                OnCompilationFailed(new CompilationFailedEventArgs(errors));
                throw ExceptionBuilder.QueryCompilationFailed(errors);
            }

            OnCompilationSucceeded(EventArgs.Empty);
            _resultIterator = IteratorCreator.Convert(DataContext.MetadataContext, true, _resultAlgebraNode);
        }