protected override TypeAttributeHandlerResult TryMap(AttributeMap item, TypeState s, TypeArgsValue a, RuntimeTypeModel model)
 {
     // we check CanUse everywhere but not family because GetContractFamily is based on CanUse
     // and CanUse is based on the settings
     // except is for SerializableAttribute which family is not returned if other families are present
     if (a.HasFamily(MetaType.AttributeFamily.SystemSerializable))
     {
         s.ImplicitFields = ImplicitFieldsMode.AllFields;
         s.ImplicitAqla   = true;
     }
     return(TypeAttributeHandlerResult.Done);
 }
예제 #2
0
 protected override TypeAttributeHandlerResult TryMap(AttributeMap item, TypeState s, TypeArgsValue a, RuntimeTypeModel model)
 {
     if (a.CanUse(AttributeType.Aqla) && CheckAqlaModelId(item, model))
     {
         s.PartialMembers.Add(item);
     }
     return(TypeAttributeHandlerResult.Done);
 }
 protected override TypeAttributeHandlerResult TryMap(AttributeMap item, TypeState s, TypeArgsValue a, RuntimeTypeModel model)
 {
     if (a.CanUse(AttributeType.Aqla) && CheckAqlaModelId(item, model))
     {
         return(_derivedTypeStrategy.TryMap(item, s));
     }
     return(TypeAttributeHandlerResult.Continue);
 }
예제 #4
0
 protected abstract TypeAttributeHandlerResult TryMap(AttributeMap item, TypeState s, TypeArgsValue a, RuntimeTypeModel model);
예제 #5
0
 protected override TypeAttributeHandlerResult TryMap(AttributeMap item, TypeState s, TypeArgsValue a, RuntimeTypeModel model)
 {
     if (a.HasFamily(MetaType.AttributeFamily.DataContractSerialier))
     {
         var    main = s.SettingsValue;
         object tmp;
         if (main.Name == null && item.TryGet("Name", out tmp))
         {
             main.Name = (string)tmp;
         }
         s.SettingsValue = main;
         return(TypeAttributeHandlerResult.Done);
     }
     return(TypeAttributeHandlerResult.Continue);
 }
예제 #6
0
        protected override TypeAttributeHandlerResult TryMap(AttributeMap item, TypeState s, TypeArgsValue a, RuntimeTypeModel model)
        {
            if (a.HasFamily(MetaType.AttributeFamily.Aqla) && CheckAqlaModelId(item, model))
            {
                var attr = item.GetRuntimeAttribute <SerializableTypeAttribute>(model);
                s.SettingsValue = attr.TypeSettings;

                s.ImplicitOnlyWriteable = attr.ImplicitOnlyWriteable;
                s.DataMemberOffset      = attr.DataMemberOffset;
                if (attr.InferTagFromNameHasValue)
                {
                    s.InferTagByName = attr.InferTagFromName;
                }
                s.ImplicitFields = attr.ImplicitFields;
                if (attr.ImplicitFirstTag != 0)
                {
                    s.ImplicitFirstTag = attr.ImplicitFirstTag;
                }

                if (s.ImplicitFields != ImplicitFieldsMode.None)
                {
                    s.ImplicitAqla = true;
                }

                return(TypeAttributeHandlerResult.Done);
            }
            return(TypeAttributeHandlerResult.Continue);
        }
예제 #7
0
        protected override TypeAttributeHandlerResult TryMap(AttributeMap item, TypeState s, TypeArgsValue a, RuntimeTypeModel model)
        {
            var main = s.SettingsValue;

            if (a.HasFamily(MetaType.AttributeFamily.ProtoBuf))
            {
                object tmp;
                if (item.TryGet("Name", out tmp))
                {
                    main.Name = (string)tmp;
                }
                if (Helpers.IsEnum(s.Type)) // note this is subtly different to AsEnum; want to do this even if [Flags]
                {
#if !FEAT_IKVM
                    // IKVM can't access EnumPassthruHasValue, but conveniently, InferTagFromName will only be returned if set via ctor or property
                    if (item.TryGet("EnumPassthruHasValue", false, out tmp) && (bool)tmp)
#endif
                    {
                        if (item.TryGet("EnumPassthru", out tmp))
                        {
                            main.EnumPassthru = (bool)tmp;
                        }
                    }
                }
                else
                {
                    if (item.TryGet("DataMemberOffset", out tmp))
                    {
                        s.DataMemberOffset = (int)tmp;
                    }

#if !FEAT_IKVM
                    // IKVM can't access InferTagFromNameHasValue, but conveniently, InferTagFromName will only be returned if set via ctor or property
                    if (item.TryGet("InferTagFromNameHasValue", false, out tmp) && (bool)tmp)
#endif
                    {
                        if (item.TryGet("InferTagFromName", out tmp))
                        {
                            s.InferTagByName = (bool)tmp;
                        }
                    }

                    if (item.TryGet("ImplicitFields", out tmp) && tmp != null)
                    {
                        s.ImplicitFields = (ImplicitFieldsMode)(int)tmp; // note that this uses the bizarre unboxing rules of enums/underlying-types
                    }
                    if (item.TryGet("SkipConstructor", out tmp))
                    {
                        main.SkipConstructor = (bool)tmp;
                    }
                    if (item.TryGet("IgnoreListHandling", out tmp))
                    {
                        main.IgnoreListHandling = (bool)tmp;
                    }
                    if (item.TryGet("AsReferenceDefault", out tmp))
                    {
                        if ((bool)tmp)
                        {
                            main.Member.Format = ValueFormat.Reference;
                        }
                        else
                        {
                            main.Member.Format = ValueSerializerBuilder.GetDefaultLegacyFormat(s.Type, model);
                        }
                    }
                    if (item.TryGet("ImplicitFirstTag", out tmp) && (int)tmp > 0)
                    {
                        s.ImplicitFirstTag = (int)tmp;
                    }
                    if (item.TryGet("ConstructType", out tmp))
                    {
                        main.ConstructType = (Type)tmp;
                    }
                }

                s.SettingsValue = main;
                return(TypeAttributeHandlerResult.Done);
            }
            return(TypeAttributeHandlerResult.Continue);
        }