コード例 #1
0
        internal static SaveBaseMembersAttribute[]? GetBaseMembersAttributes(ref IntermediateMappingContext ctx, Type type)
        {
            SaveBaseMembersAttribute[] attr = (SaveBaseMembersAttribute[])type.GetCustomAttributes <SaveBaseMembersAttribute>(false);
            if (attr.Length == 0)
            {
                return(null);
            }

            MappingHelpers.ProcessVersionedAttributes(ref ctx.HighestVersion, attr);
            return(attr);
        }
コード例 #2
0
        internal static void UpdateContextFromItem(ref IntermediateMappingContext ctx, IntermediateItem newItem)
        {
            // Check ordering
            if (ctx.TranslationCurrentOrderInfo != -1)
            {
                if (newItem.Order >= ctx.TranslationCurrentOrderInfo)
                {
                    ctx.TranslationCurrentOrderInfo = newItem.Order;
                }
                else
                {
                    ctx.TranslationCurrentOrderInfo = -1;
                }
            }

            MappingHelpers.UpdateHighestVersionFromRange(ref ctx.HighestVersion, newItem.StartVer, newItem.EndVer);
        }
コード例 #3
0
        public static uint CreateIntermediateObjectInfo(Type type, SaveMembersMode mode, out IntermediateObjectInfo intermediateInfo)
        {
            Debug.Assert(Attribute.IsDefined(type, typeof(SaveMembersAttribute)));

            var ctx = new IntermediateMappingContext(type, mode);

            // Coming soon: Settings-based mapping
            intermediateInfo = new IntermediateObjectInfo
            {
                Members = IntermediateReflectionMapper.FillInfo(ref ctx),
                BaseMemberAttributes = GetBaseMembersAttributes(ref ctx, type)
            };

            if (ctx.TranslationCurrentOrderInfo == -1)
            {
                Array.Sort(intermediateInfo.Members);
            }

            return(ctx.HighestVersion);
        }