Exemple #1
0
        public virtual void CancelEdit(IUserEditable originatingObject)
        {
            if (!IsEditing || !ReferenceEquals(_originatingEditingObject, originatingObject))
            {
                return;
            }

            IsEditing = false;

            var accessor = GetTypeAccessor();

            foreach (var propertyName in GetBackupProperties())
            {
                var value = BackupValues[propertyName];
                RemoveTracker(propertyName);

                if (!IsEqualToBackup(accessor[this, propertyName], propertyName))
                {
                    accessor[this, propertyName] = value;
                }

                if (value is IUserEditable editable && GetEditableProperties().Contains(propertyName))
                {
                    editable.CancelEdit(this);
                }
            }

            UserModifiedProperties.Clear();
            IsUserModified            = false;
            _originatingEditingObject = null;
        }
Exemple #2
0
        public virtual void EndEdit(IUserEditable originatingObject)
        {
            if (!IsEditing || !ReferenceEquals(_originatingEditingObject, originatingObject))
            {
                return;
            }

            IsEditing = false;
            foreach (var propertyName in GetBackupProperties())
            {
                var value = PropertyHelper.GetPropertyValue(this, propertyName);

                if (GetEditableProperties().Contains(propertyName) && value is IUserEditable editable)
                {
                    RemoveTracker(propertyName);
                    editable.EndEdit(this);
                }
            }

            UserModifiedProperties.Clear();
            IsUserModified = false;


            _originatingEditingObject = null;
        }