Пример #1
0
        protected override System.Linq.Expressions.Expression VisitDeferredSectionExpression(DeferredSectionExpression dsex)
        {
#if netstandard
            var method = new Action <object, BindingContext, Action <TextWriter, object>, Action <TextWriter, object> >(RenderSection).GetMethodInfo();
#else
            var method = new Action <object, BindingContext, Action <TextWriter, object>, Action <TextWriter, object> >(RenderSection).Method;
#endif
            System.Linq.Expressions.Expression   path      = HandlebarsExpression.Path(dsex.Path.Path.Substring(1));
            System.Linq.Expressions.Expression   context   = CompilationContext.BindingContext;
            System.Linq.Expressions.Expression[] templates = GetDeferredSectionTemplates(dsex);

            return(System.Linq.Expressions.Expression.Call(method, new[] { path, context }.Concat(templates)));
        }
Пример #2
0
 public override IEnumerable <object> ConvertTokens(IEnumerable <object> sequence)
 {
     foreach (var item in sequence)
     {
         if (item is WordExpressionToken)
         {
             yield return(HandlebarsExpression.Path(((WordExpressionToken)item).Value));
         }
         else
         {
             yield return(item);
         }
     }
 }
        private static object ParseValue(string value)
        {
            if (value.StartsWith("'") || value.StartsWith("\""))
            {
                return(value.Trim('\'', '"'));
            }

            bool boolValue;

            if (bool.TryParse(value, out boolValue))
            {
                return(boolValue);
            }

            int intValue;

            if (int.TryParse(value, out intValue))
            {
                return(intValue);
            }

            return(HandlebarsExpression.Path(value));
        }