Ejemplo n.º 1
0
 //------------------------------------------------------------------------------------
 /// <summary>
 /// Ensures that the backing store for the given item is synced with the current
 /// contents of the item.
 /// </summary>
 //------------------------------------------------------------------------------------
 public void WriteToBackingStoreBeforeSave(IsOpenedForEdit isOpen)
 {
     foreach (ItemProperty itemProperty in m_changedProperties)
     {
         // Leave the Status property as it is, since the value in memory represents
         // the intended status *after* the save, and we don't want to confuse PS.
         if (itemProperty.PublicPropName != StoreItem.StatusPropName)
         {
             Store.SetItemBackingValue(this, itemProperty.DSPropName, itemProperty.PublicPropName, itemProperty.CurrentValue, isOpen);
         }
     }
 }
Ejemplo n.º 2
0
        //------------------------------------------------------------------------------------
        /// <summary>
        /// For the given StoreItem, set the current value of the specified property directly
        /// into the backing store.  If isOpen is true, the item will be assumed to already
        /// be open for edit, and won't be opened again.
        /// </summary>
        //------------------------------------------------------------------------------------
        public void SetItemBackingValue(StoreItem item, string dsPropName, string publicPropName, object value, IsOpenedForEdit isOpen = IsOpenedForEdit.No)
        {
            DatastoreItem dsItem = item.DSItem;

            if (dsItem != null)
            {
                if (isOpen == IsOpenedForEdit.No && item.ID != 0)
                {
                    OpenForEdit(item.DSItem);
                }

                Field field = dsItem.Fields[dsPropName];
                if (!field.IsReadOnly)
                {
                    object finalValue;
                    if (!CompositeRegistry.GetCompositeFromValue(dsItem, dsPropName, publicPropName, value, out finalValue))
                    {
                        finalValue = value;
                    }

                    field.Value = finalValue;
                }
            }
        }