protected override MemberHandlerResult TryMap(MemberState s, ref MemberMainSettingsValue main, MemberInfo member, RuntimeTypeModel model)
        {
            if (s.Input.IsEnumValueMember)
            {
                return(MemberHandlerResult.NotFound);
            }
            // always consider ProtoMember if not strict Aqla
            // even if no [ProtoContract] was declared!
            if (!s.Input.CanUse(AttributeType.ProtoBuf))
            {
                return(MemberHandlerResult.NotFound);
            }
            if (HasProtobufNetIgnore(s.Input.Attributes, model))
            {
                return(MemberHandlerResult.Ignore);
            }
            var attrib = AttributeMap.GetAttribute(s.Input.Attributes, "ProtoBuf.ProtoMemberAttribute");

            if (attrib != null)
            {
                var r = _strategy.TryRead(attrib, s, member, model);
                // we have ref!
                main = s.MainValue;
                return(r);
            }
            return(MemberHandlerResult.NotFound);
        }
Пример #2
0
        protected override MemberHandlerResult TryMap(MemberState s, ref MemberMainSettingsValue main, MemberInfo member, RuntimeTypeModel model)
        {
            if (s.Input.IsEnumValueMember)
            {
                return(MemberHandlerResult.NotFound);
            }
            if (!s.Input.CanUse(AttributeType.ProtoBuf))
            {
                return(MemberHandlerResult.NotFound);
            }
            if (HasProtobufNetIgnore(s.Input.Attributes, model))
            {
                return(MemberHandlerResult.Ignore);
            }
            MemberHandlerResult result = MemberHandlerResult.NotFound;

            foreach (AttributeMap ppma in s.Input.PartialMembers)
            {
                object tmp;
                if (!ppma.TryGet("MemberName", out tmp) || tmp as string != member.Name)
                {
                    continue;
                }

                if (ppma.AttributeType.FullName == "ProtoBuf.ProtoPartialIgnoreAttribute")
                {
                    return(MemberHandlerResult.Ignore);
                }

                MemberHandlerResult newResult;
                if (ppma.AttributeType.FullName == "ProtoBuf.ProtoPartialMemberAttribute")
                {
                    newResult = _strategy.TryRead(ppma, s, member, model);
                    // we have ref!
                    main = s.MainValue;
                }
                else
                {
                    newResult = MemberHandlerResult.NotFound;
                }

                if (newResult == MemberHandlerResult.Done)
                {
                    return(MemberHandlerResult.Done);
                }
                if (newResult == MemberHandlerResult.Partial)
                {
                    result = newResult;
                }
            }
            return(result);
        }