//------------------------------------------------------------------------------------ /// <summary> /// Syncs the changed property list based on the current state of the given property. /// </summary> //------------------------------------------------------------------------------------ private void UpdateChangedPropertiesList(ItemProperty itemProperty) { if (itemProperty.IsValueChanged()) { if (!m_changedProperties.Contains(itemProperty)) { m_changedProperties.Add(itemProperty); } } else { if (m_changedProperties.Contains(itemProperty)) { m_changedProperties.Remove(itemProperty); } } }
//------------------------------------------------------------------------------------ /// <summary> /// Called when this item has been refreshed from the backing store. /// </summary> //------------------------------------------------------------------------------------ public void SyncItemFromStore(DatastoreItem dsItem) { // First, set the secondary backing store cache to the one just received. DSItem = dsItem; foreach (KeyValuePair <string, ItemProperty> kvp in ItemProperties) { // If our value hasn't changed, accept the value from the back-end store // if it's different from ours. ItemProperty itemProperty = kvp.Value; if (!itemProperty.IsValueChanged()) { SyncPropertyFromStore(itemProperty); } // Otherwise, put our in-memory changed value into the new backing store cache, so // that our value will still get persisted on the next commit operation. else { Store.SetItemBackingValue(this, itemProperty.DSPropName, itemProperty.PublicPropName, itemProperty.CurrentValue); } } }