Example #1
0
        protected virtual MemberHandlerResult ProcessHandlers(MemberState state)
        {
            MemberHandlerResult result = MemberHandlerResult.NotFound;

            foreach (var handler in Handlers)
            {
                switch (result = handler.TryMap(state))
                {
                case MemberHandlerResult.Ignore:
                    return(result);

                case MemberHandlerResult.Done:
                    break;
                }
            }
            return(result);
        }
Example #2
0
        public virtual MappedMember Map(MemberArgsValue args)
        {
            if (args.Member == null || (args.Family == MetaType.AttributeFamily.None && !args.IsEnumValueMember))
            {
                return(null);
            }
            if (args.Member.Name == "Values")
            {
            }
            if (args.IsEnumValueMember)
            {
                args.IsForced = true;
            }
            var state = new MemberState(args);
            MemberMainSettingsValue m = state.MainValue;

            m.Tag           = int.MinValue;
            state.MainValue = m;

            if (ProcessHandlers(state) == MemberHandlerResult.Ignore || (state.MainValue.Tag < state.MinAcceptFieldNumber && !state.Input.IsForced))
            {
                return(null);
            }

            if (!state.SerializationSettings.HasSettingsSpecified(0))
            {
                state.SerializationSettings.SetSettings(state.SerializationSettings.GetSettingsCopy(0), 0);
            }

            if (state.SerializationSettings.DefaultLevel == null)
            {
                state.SerializationSettings.DefaultLevel = new ValueSerializationSettings.LevelValue(state.SerializationSettings.GetSettingsCopy(0).Basic.MakeDefaultNestedLevel());
            }

            return(new MappedMember(state)
            {
                ForcedTag = state.Input.IsForced || state.Input.InferTagByName
            });
        }