private static void _Merge(ProgramSettings source, object sourceRoot, object destRoot) { try { foreach (PropertyInfo info in sourceRoot.GetType().GetProperties()) { try { if (info.GetCustomAttributes(typeof(OptionsRootAttribute), false).Length > 0) { _Merge(source, info.GetValue(sourceRoot, null), info.GetValue(destRoot, null)); } else if (((source.Fields == null) || (Array.IndexOf<string>(source.Fields, info.Name) >= 0)) && (info.CanWrite && (info.GetSetMethod() != null))) { object obj2 = info.GetValue(sourceRoot, null); object obj3 = info.GetValue(destRoot, null); if (((obj2 != null) && !obj2.Equals(obj3)) && (obj2 != obj3)) { destRoot.GetType().GetProperty(info.Name).SetValue(destRoot, obj2, null); } } } catch (Exception exception) { ErrorLog.WriteLine(exception); } } } catch (Exception exception2) { ErrorLog.WriteLine(exception2); } }
public static void OverwriteSettings(ProgramSettings source, ProgramSettings destination) { if (source.GetType() != destination.GetType()) { ErrorLog.WriteLine("Types do not match between settings objects; source: {0}, destination: {1}", new object[] { source.GetType(), destination.GetType() }); DlgMessage.ShowDialog(Loc.Get("<LOC>An error occured while saving settings, some changes may not take effect and it is recommended you restart the application.")); } _OverwriteSettings(source, destination); }
public object OnSaveLoad(object data, ProgramSettings.SaveLoadDirections direction) { if (data != null) { if (direction == ProgramSettings.SaveLoadDirections.Load) { return Encryption.Decode(data.ToString(), EncodingMethods.Base64); } if (direction == ProgramSettings.SaveLoadDirections.Save) { return Encryption.Encode(data.ToString(), EncodingMethods.Base64); } } return data; }
public static ProgramSettings Merge(ProgramSettings source, ProgramSettings destination) { try { if (source.GetType() != destination.GetType()) { ErrorLog.WriteLine("Types do not match between settings objects; source: {0}, destination: {1}", new object[] { source.GetType(), destination.GetType() }); MessageBox.Show(Loc.Get("<LOC>An error occured while saving settings, some changes may not take effect and it is recommended you restart the application.")); } _Merge(source, source, destination); return destination; } catch (Exception exception) { ErrorLog.WriteLine(exception); return destination; } }