//------------------------------------------------------------------------------ public void UpdateMethods(MethodSerializerAttribute attribute) { m_loadMethod = attribute.LoadMethod; m_saveMethod = attribute.SaveMethod; m_deleteMethod = attribute.DeleteMethod; m_containsMethod = attribute.ContainsMethod; m_synchronizeMethod = attribute.SynchronizeMethod; }
public MethodSerializerForField(MethodSerializerAttribute attribute, object serializerObj) : base(attribute, serializerObj) { }
//------------------------------------------------------------------------------ public MethodSerializer(MethodSerializerAttribute attribute, object serializerObj) { UpdateMethods(attribute); m_serializerObj = serializerObj; }
//------------------------------------------------------------------------------ static ISettingsSerializer GetSerializerForMember(SettingsObjectInfo settingsObjectInfo, ref Dictionary <Type, KeyValuePair <ISettingsSerializer, bool> > serializersCache) { if (settingsObjectInfo.SettingAttributeType == null) { if (settingsObjectInfo.MemberInfo == null) { throw new ArgumentNullException(nameof(settingsObjectInfo.MemberInfo)); } SettingBaseAttribute settingBaseAttr = settingsObjectInfo.MemberInfo.GetCustomAttribute <SettingBaseAttribute>(); if (settingBaseAttr == null) { return(null); } settingsObjectInfo.SettingAttributeType = settingBaseAttr.GetType(); } ISettingsSerializer serializer = settingsObjectInfo.ForegroundSerializer; bool skipExternalSerializer = false; ISettingsSerializer attributeSerializer = null; // try to get setting attribute corresponding serializer if (serializer == null) { var serializerInfo = GetSerializerInfoDependFromSettingAttributeType(settingsObjectInfo.Settings, settingsObjectInfo.SettingAttributeType, ref serializersCache); attributeSerializer = serializerInfo.Key; skipExternalSerializer = serializerInfo.Value; } if (settingsObjectInfo.MemberInfo != null) { // try to get setting (field) serializer if (serializer == null && !skipExternalSerializer) { SerializerAttribute serializerAttr = settingsObjectInfo.MemberInfo.GetCustomAttribute <SerializerAttribute>(); MethodSerializerAttribute methodSerializerAttrForField = settingsObjectInfo.MemberInfo.GetCustomAttribute <MethodSerializerAttribute>(); if (methodSerializerAttrForField != null) { serializer = new MethodSerializerForField(methodSerializerAttrForField, settingsObjectInfo.Settings); } else if (serializerAttr != null) { serializer = GetCustomSerializer(settingsObjectInfo.Settings, serializerAttr.Type, ref serializersCache).Key; } } } // try to get class serializer if (serializer == null && !skipExternalSerializer) { SerializerAttribute serializerAttr = settingsObjectInfo.Settings.GetType().GetTypeInfo(). GetCustomAttribute <SerializerAttribute>(); MethodSerializerAttribute methodSerializerAttrForClass = settingsObjectInfo.Settings.GetType().GetTypeInfo(). GetCustomAttribute <MethodSerializerAttribute>(); if (methodSerializerAttrForClass != null) { serializer = new MethodSerializerForClass(methodSerializerAttrForClass, settingsObjectInfo.Settings); } else if (serializerAttr != null) { serializer = GetCustomSerializer(settingsObjectInfo.Settings, serializerAttr.Type, ref serializersCache).Key; } } // try to get library serializer if (serializer == null && !skipExternalSerializer) { serializer = SettingsBaseConfiguration.Serializer; } // try to get attribute serializer in case if allowed if (serializer == null && !skipExternalSerializer) { serializer = attributeSerializer; } return(serializer); }