コード例 #1
0
 private TranslationContext(
     ExpressionAnalysisVisitor analyzer,
     Translator globalTranslator,
     TranslationSettings settings)
 {
     _analyzer         = analyzer;
     _globalTranslator = globalTranslator;
     Settings          = settings;
 }
コード例 #2
0
        /// <summary>
        /// Creates a <see cref="TranslationContext"/> containing information about the given
        /// <paramref name="expression"/>.
        /// </summary>
        /// <param name="expression">
        /// The <see cref="Expression"/> for which to create the <see cref="TranslationContext"/>.
        /// </param>
        /// <param name="globalTranslator">
        /// A global <see cref="Translator"/> delegate with which to perform translations.
        /// </param>
        /// <param name="configuration">The configuration to use for the translation, if required.</param>
        /// <returns>A <see cref="TranslationContext"/> for the given<paramref name="expression"/>.</returns>
        public static TranslationContext For(
            Expression expression,
            Translator globalTranslator,
            Func <TranslationSettings, TranslationSettings> configuration = null)
        {
            var analyzer = ExpressionAnalysisVisitor.Analyse(expression);
            var settings = GetTranslationSettings(configuration);

            return(new TranslationContext(analyzer, globalTranslator, settings));
        }
コード例 #3
0
            public static ExpressionAnalysisVisitor Analyse(Expression expression)
            {
                var analyzer = new ExpressionAnalysisVisitor();

                var coreExpression = GetCoreExpression(expression);

                if ((expression.NodeType != ExpressionType.Extension) || expression.CanReduce)
                {
                    analyzer.Visit(coreExpression);
                }

                return(analyzer);
            }