Пример #1
0
 protected override Expression VisitHashParametersExpression(HashParametersExpression hpex)
 {
     return(Expression.Call(
                Expression.Constant(this),
                new Func <BindingContext, HashParametersExpression, object>(ResolveParameters).Method,
                CompilationContext.BindingContext,
                Expression.Constant(hpex)));
 }
Пример #2
0
        protected override Expression VisitHashParametersExpression(HashParametersExpression hpex)
        {
            return(Expression.Call(
                       Expression.Constant(this),
#if netstandard
                       new Func <BindingContext, HashParametersExpression, object>(ResolveParameters).GetMethodInfo(),
#else
                       new Func <BindingContext, HashParametersExpression, object>(ResolveParameters).Method,
#endif
                       CompilationContext.BindingContext,
                       Expression.Constant(hpex)));
        }
Пример #3
0
        protected override Expression VisitHashParametersExpression(HashParametersExpression hpex)
        {
            var addMethod = typeof(HashParameterDictionary).GetMethod("Add", new[] { typeof(string), typeof(object) });

            var elementInits = new List <ElementInit>();

            foreach (var parameter in hpex.Parameters)
            {
                elementInits.Add(Expression.ElementInit(
                                     addMethod,
                                     Expression.Constant(parameter.Key),
                                     Visit(parameter.Value)));
            }

            return(Expression.ListInit(
                       Expression.New(typeof(HashParameterDictionary).GetConstructor(new Type[0])),
                       elementInits));
        }
Пример #4
0
        private object ResolveParameters(BindingContext context, HashParametersExpression hpex)
        {
            var parameters = new HashParameterDictionary();

            foreach (var parameter in hpex.Parameters)
            {
                var path = parameter.Value as PathExpression;

                if (path != null)
                {
                    parameters.Add(parameter.Key, ResolvePath(context, path.Path));
                }
                else
                {
                    parameters.Add(parameter.Key, parameter.Value);
                }
            }

            return(parameters);
        }
        protected virtual Expression VisitHashParametersExpression(HashParametersExpression hpex)
        {
            var  parameters        = new Dictionary <string, Expression>();
            bool parametersChanged = false;

            foreach (string key in hpex.Parameters.Keys)
            {
                Expression value = Visit(hpex.Parameters[key]);
                parameters.Add(key, value);
                if (value != hpex.Parameters[key])
                {
                    parametersChanged = true;
                }
            }
            if (parametersChanged)
            {
                return(HandlebarsExpression.HashParametersExpression(parameters));
            }
            return(hpex);
        }
 protected virtual Expression VisitHashParametersExpression(HashParametersExpression hpex)
 {
     return hpex;
 }
Пример #7
0
 protected virtual Expression VisitHashParametersExpression(HashParametersExpression hpex)
 {
     return(hpex);
 }
Пример #8
0
 protected override Expression VisitHashParametersExpression(HashParametersExpression hpex)
 {
     return Expression.Call(
         Expression.Constant(this),
         new Func<BindingContext, HashParametersExpression, object>(ResolveParameters).Method,
         CompilationContext.BindingContext,
         Expression.Constant(hpex));
 }
Пример #9
0
        private object ResolveParameters(BindingContext context, HashParametersExpression hpex)
        {
            var parameters = new Dictionary<string, object>();

            foreach (var parameter in hpex.Parameters)
            {
                var path = parameter.Value as PathExpression;

                if (path != null)
                {
                    parameters.Add(parameter.Key, ResolvePath(context, path.Path));
                }
                else
                {
                    parameters.Add(parameter.Key, parameter.Value);
                }
            }

            return parameters;
        }
Пример #10
0
        protected override Expression VisitHashParametersExpression(HashParametersExpression hpex)
        {
            return Expression.Call(
                Expression.Constant(this),
#if netstandard
                new Func<BindingContext, HashParametersExpression, object>(ResolveParameters).GetMethodInfo(),
#else
                new Func<BindingContext, HashParametersExpression, object>(ResolveParameters).Method,
#endif
                CompilationContext.BindingContext,
                Expression.Constant(hpex));
        }