private void UpdateValue(object newValue) { var oldValue = value; bool changed = !Equals(oldValue, newValue); if (changed && ShouldNotify && !Profile.IsDiscarding) { var actionItem = new PropertyChangedActionItem("Value", this, oldValue); Profile.ActionStack.Add(actionItem); Profile.NotifyEntryChanged(Name); } value = newValue; }
private static void ChangeCurrentProfile(SettingsProfile oldProfile, SettingsProfile newProfile) { if (oldProfile == null) { throw new ArgumentNullException("oldProfile"); } if (newProfile == null) { throw new ArgumentNullException("newProfile"); } currentProfile = newProfile; foreach (var key in SettingsKeys) { object oldValue; oldProfile.GetValue(key.Key, out oldValue, true, false); object newValue; newProfile.GetValue(key.Key, out newValue, true, false); var oldList = oldValue as IList; var newList = newValue as IList; bool isDifferent; if (oldList != null && newList != null) { isDifferent = oldList.Count != newList.Count; for (int i = 0; i < oldList.Count && !isDifferent; ++i) { if (!Equals(oldList[i], newList[i])) { isDifferent = true; } } } else { isDifferent = !Equals(oldValue, newValue); } if (isDifferent) { newProfile.NotifyEntryChanged(key.Key); } } // Changes have been notified, empty the list of modified settings. newProfile.ValidateSettingsChanges(); }