/// <summary>
 /// Reverts the value of a property
 /// </summary>
 public void RevertPropertyValue(string property)
 {
     if (!DiscartableChangesControl)
     {
         throw new ApplicationException("Discartable Changes Control is not active.");
     }
     else if (!this.IsDirty())
     {
         throw new ApplicationException("The data is not dirty.");
     }
     else
     {
         ValueChangedDescriptorCollection diferences = GetChanges();
         if (!diferences.Contains(property))
         {
             throw new ApplicationException("The property is not changed.");
         }
         else
         {
             object originalValue = diferences[property].OriginalValue;
             SetData(property, originalValue);
             if (diferences.Count == 1)
             {
                 backupDiscardChanges = null;
             }
         }
     }
 }
        /// <summary>
        /// Returns the diferences between current and backupData.
        /// </summary>
        public ValueChangedDescriptorCollection GetDifferences(object backupData)
        {
            Hashtable backup = (Hashtable)backupData;
            ValueChangedDescriptorCollection changes = new ValueChangedDescriptorCollection();

            foreach (string key in data.Keys)
            {
                if (!backup.ContainsKey(key))
                {
                    changes.Add(key, null, data[key]);
                }
                else if (!backup[key].Equals(data[key]))
                {
                    changes.Add(key, backup[key], data[key]);
                }
            }

            foreach (string key in backup.Keys)
            {
                if (!data.ContainsKey(key))
                {
                    changes.Add(key, backup[key], null);
                }
            }

            return(changes);
        }
 /// <summary>
 /// Gets the changes respect the original version.
 /// </summary>
 /// <remarks>
 /// To use this, DiscartableChangesControl has to be true.
 /// </remarks>
 public ValueChangedDescriptorCollection GetChanges()
 {
     if (!DiscartableChangesControl)
     {
         throw new ApplicationException("Discartable Changes Control is not active.");
     }
     else if (backupDiscardChanges == null)
     {
         return(ValueChangedDescriptorCollection.CreateEmpty());
     }
     else
     {
         return(GetDifferences(backupDiscardChanges));
     }
 }