protected override Expression VisitMemberAccess(MemberExpression expression)
            {
                var member = expression.Member;

                if (member.MemberType == MemberTypes.Property)
                {
                    if (member.DeclaringType.FullName == typeof(VariableQueryArgument).FullName || member.DeclaringType.FullName == typeof(VariableQueryArgumentList).FullName)
                    {
                        var instanceExpression = Visit(expression.Expression) as ConstantExpression;
                        if (!ReferenceEquals(null, instanceExpression))
                        {
                            var instanceType = instanceExpression.Type;
                            if (instanceType.IsGenericType && instanceType.Type.GetGenericTypeDefinition() == typeof(VariableQueryArgument <>))
                            {
                                var valueType         = instanceType.GenericArguments.Single();
                                var valuePropertyInfo = new PropertyInfo("Value", valueType, instanceType);

                                var newMemberExpression = new MemberExpression(instanceExpression, valuePropertyInfo);
                                return(newMemberExpression);
                            }
                        }
                    }
                }

                return(base.VisitMemberAccess(expression));
            }
예제 #2
0
        public void ResolveMemberInfo_should_return_original_property_info()
        {
            var typeResolver = new TypeResolver();

            System.Reflection.TypeInfo     type           = typeof(TypeHiding).GetTypeInfo();
            System.Reflection.PropertyInfo propertyInfo   = type.GetDeclaredProperty(nameof(TypeHiding.Property));
            Aqua.TypeSystem.PropertyInfo   mappedProperty = new Aqua.TypeSystem.PropertyInfo(propertyInfo);
            System.Reflection.MemberInfo   resolvedMember = mappedProperty.ResolveMemberInfo(typeResolver);

            resolvedMember.ShouldBe(propertyInfo);
        }