public Expression Build(ParameterInfo parameter, Expression context)
        {
            GlobalStateAttribute attribute = parameter.GetCustomAttribute <GlobalStateAttribute>() !;

            ConstantExpression key =
                attribute.Key is null
                    ? Expression.Constant(parameter.Name, typeof(string))
                    : Expression.Constant(attribute.Key, typeof(string));

            MemberExpression contextData = Expression.Property(context, _contextData);

            return(IsStateSetter(parameter.ParameterType)
                ? BuildSetter(parameter, key, contextData)
                : BuildGetter(parameter, key, contextData));
        }
Example #2
0
        public override Expression Compile(
            Expression context,
            ParameterInfo parameter,
            Type sourceType)
        {
            GlobalStateAttribute attribute =
                parameter.GetCustomAttribute <GlobalStateAttribute>();

            ConstantExpression key =
                attribute.Key is null
                    ? Expression.Constant(parameter.Name, typeof(string))
                    : Expression.Constant(attribute.Key, typeof(string));

            MemberExpression contextData =
                Expression.Property(context, ContextData);

            return(Compile(parameter, key, contextData));
        }