Beispiel #1
0
        private void UpdateValue(object newValue)
        {
            var  oldValue = value;
            bool changed  = !Equals(oldValue, newValue);

            if (changed && ShouldNotify && !Profile.IsDiscarding)
            {
                var actionItem = new PropertyChangedActionItem("Changed value", "Value", this, oldValue, Enumerable.Empty <IDirtiable>(), true);
                Profile.ActionStack.Add(actionItem);
                Profile.NotifyEntryChanged(Name);
            }
            value = newValue;
        }
Beispiel #2
0
        private void ChangeCurrentProfile(SettingsProfile oldProfile, SettingsProfile newProfile)
        {
            if (oldProfile == null)
            {
                throw new ArgumentNullException("oldProfile");
            }
            if (newProfile == null)
            {
                throw new ArgumentNullException("newProfile");
            }
            currentProfile = newProfile;

            lock (SettingsLock)
            {
                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();
        }
Beispiel #3
0
        private void UpdateValue(object newValue)
        {
            var  oldValue = value;
            bool changed  = !Equals(oldValue, newValue);

            if (changed && ShouldNotify && !Profile.IsDiscarding)
            {
                using (Profile.TransactionStack.CreateTransaction())
                {
                    Profile.TransactionStack.PushOperation(new SettingsEntryChangeValueOperation(this, oldValue));
                }
                Profile.NotifyEntryChanged(Name);
            }
            value = newValue;
        }
Beispiel #4
0
        private 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();
        }