Exemplo n.º 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         = !XmlSource.IsValid;
            HasCustomizations = XmlSource.IsAutoUpdated == false || XmlSource.IsEmptyMetadata(XmlSource.ForwardInstance) == false || ChildrenHaveAnyCustomizations();
            if (HasCustomizations == false && XmlSource.ReverseInstance != null)
            {
                // remove customizations if solely due to child customizations no longer present
                XmlSource.IsAutoUpdated  = true;
                XmlSource.SpecSourceName = XmlSource.ReverseInstance.SpecSourceName;
                XmlSource.ResetModified(XmlSource.ReverseInstance.IsModified);
                XmlSource.ResetLoaded(XmlSource.ReverseInstance.IsLoaded);
                if (!XmlSource.IsIdenticalMetadata(XmlSource.ReverseInstance))
                {
                    HasCustomizations       = true;
                    XmlSource.IsAutoUpdated = false;
                }
            }
            if (HasCustomizations == false)
            {
                // clear customizations
                XmlSource.ForwardInstance = null;
                XmlSource.ReverseInstance = null;
                XmlSource.IsAutoUpdated   = true;
            }
            OnPropertyChanged("Items");
            OnPropertyChanged("HasCustomizations");
            OnPropertyChanged("HasErrors");
        }