Example #1
0
        public new void VisitMember(MemberExpression expr_)
        {
            //cb.append("memberExpr Type,Member=");
            //cb.append(expr_.Type.Name);
            MemberInfo mi = expr_.Member;

            if (JsonPropertyAttribute.IsDefined(mi, typeof(JsonPropertyAttribute)))
            {
                Attribute atr  = pr.IsUsingAttribute <JsonPropertyAttribute>(mi);
                Attribute atr2 = JsonPropertyAttribute.GetCustomAttribute(mi, typeof(JsonPropertyAttribute));
                string    res  = pr.GetJsonPropertyName(atr);
                nestedProperties.Push(res);
            }
            else
            {
                string mn = expr_.Member.ReflectedType.Name;
                nestedProperties.Push(expr_.Member.Name);
            }
            Visit(expr_.Expression);
        }
Example #2
0
        public new void VisitMemberInit(MemberInitExpression expr_)
        {
            //cb.append("memberExpr Type,Member=");
            //cb.append(expr_.Type.Name);
            IReadOnlyCollection <MemberBinding> memeberBinding = expr_.Bindings;

            foreach (MemberBinding mb in memeberBinding)
            {
                MemberInfo mi = mb.Member;
                if (JsonPropertyAttribute.IsDefined(mi, typeof(JsonPropertyAttribute)))
                {
                    Attribute atr  = pr.IsUsingAttribute <JsonPropertyAttribute>(mi);
                    Attribute atr2 = JsonPropertyAttribute.GetCustomAttribute(mi, typeof(JsonPropertyAttribute));
                    string    res  = pr.GetJsonPropertyName(atr);
                    nestedProperties.Push(res);
                }
                else
                {
                    string mn = mi.Name;
                    nestedProperties.Push(mn);
                }
            }

            /*
             * if(JsonPropertyAttribute.IsDefined(mi,typeof(JsonPropertyAttribute)))
             * {
             *  Attribute atr=pr.IsUsingAttribute<JsonPropertyAttribute>(mi);
             *  Attribute atr2=JsonPropertyAttribute.GetCustomAttribute(mi, typeof(JsonPropertyAttribute));
             *  string res=pr.GetJsonPropertyName(atr);
             *  nestedProperties.Push(res);
             * }else{
             *  string mn=expr_.Member.ReflectedType.Name;
             *  nestedProperties.Push(expr_.Member.Name);
             * }
             */
        }