public IntermediateMappingContext(Type classType, SaveMembersMode mode) { ClassType = classType; Mode = mode; TranslationCurrentOrderInfo = 0; UnskippedMemberCount = 0; HighestVersion = 0; }
static FieldInfo[] GetFields(BindingFlags bindingFlags, Type classType, SaveMembersMode mode) { FieldInfo[]? fields = Array.Empty <FieldInfo>(); if ((mode & SaveMembersMode.Fields) > 0) { fields = classType.GetFields(bindingFlags); } return(fields); }
// Coming soon: Settings-based mapping public static bool CheckIfEligibleAndGetSaveMode(Type type, out SaveMembersMode mode) { mode = SaveMembersMode.Fields; SaveMembersAttribute?attribute = type.GetCustomAttribute <SaveMembersAttribute>(false); if (attribute == null) { return(false); } mode = attribute.Mode; return(true); }
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); }
static PropertyInfo[] GetProperties(BindingFlags bindingFlags, Type classType, SaveMembersMode mode) { PropertyInfo[]? properties = Array.Empty <PropertyInfo>(); if ((mode & SaveMembersMode.Properties) > 0) { properties = classType.GetProperties(bindingFlags); } return(properties); }
public SaveMembersAttribute(SaveMembersMode mode = SaveMembersMode.Properties) => Mode = mode;