示例#1
0
        public void Visit(VariableReference variable)
        {
            var getter = context.CompiledGetter(variable.Path);

            getter = CompoundExpression.NullCheck(getter, "");
            getter = Expression.Call(getter, context.TargetType.GetMethod("ToString"));

            if (variable.Escaped)
            {
                parts.Add(Expression.Call(null, typeof(Encoders).GetMethod("DefaultHtmlEncode"), getter));
            }
            else
            {
                parts.Add(getter);
            }
        }
示例#2
0
        public void Visit(VariableReference variable)
        {
            var getter = context.CompiledGetter(variable.Path);

            getter = CompoundExpression.NullCheck(getter, "");
            getter = Expression.Call(getter, context.TargetType.GetMethod("ToString"));

            if (variable.Escaped)
            {
                var escaperProperty = typeof(Encoders).GetProperty("HtmlEncode", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
                var escaperMethod   = (Delegate)escaperProperty.GetValue(null, null);
                parts.Add(CompoundExpression.IndentOnLineEnd(Expression.Call(null, escaperMethod.Method, getter), context));
            }
            else
            {
                parts.Add(CompoundExpression.IndentOnLineEnd(getter, context));
            }
        }