예제 #1
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method refreshes the view model.</summary>
        ///
        /// <param name="refreshChildren">Flag indicating whether children should be refreshed.</param>
        ///--------------------------------------------------------------------------------
        public void Refresh(bool refreshChildren, int refreshLevel = 0)
        {
            if (refreshChildren == true || refreshLevel > 0)
            {
            }

            #region protected
            #endregion protected

            HasErrors         = !PropertyInstance.IsValid;
            HasCustomizations = PropertyInstance.IsAutoUpdated == false || PropertyInstance.IsEmptyMetadata(PropertyInstance.ForwardInstance) == false || ChildrenHaveAnyCustomizations();
            if (HasCustomizations == false && PropertyInstance.ReverseInstance != null)
            {
                // remove customizations if solely due to child customizations no longer present
                PropertyInstance.IsAutoUpdated  = true;
                PropertyInstance.SpecSourceName = PropertyInstance.ReverseInstance.SpecSourceName;
                PropertyInstance.ResetModified(PropertyInstance.ReverseInstance.IsModified);
                PropertyInstance.ResetLoaded(PropertyInstance.ReverseInstance.IsLoaded);
                if (!PropertyInstance.IsIdenticalMetadata(PropertyInstance.ReverseInstance))
                {
                    HasCustomizations = true;
                    PropertyInstance.IsAutoUpdated = false;
                }
            }
            if (HasCustomizations == false)
            {
                // clear customizations
                PropertyInstance.ForwardInstance = null;
                PropertyInstance.ReverseInstance = null;
                PropertyInstance.IsAutoUpdated   = true;
            }
            OnPropertyChanged("Items");
            OnPropertyChanged("HasCustomizations");
            OnPropertyChanged("HasErrors");
        }