Example #1
0
 private static void RestoreMemento(IViewContent viewContent, VelerSoftware.SZC.Debugger.Core.Properties memento)
 {
     if (memento != null)
     {
         ((IMementoCapable)viewContent).SetMemento(memento);
     }
 }
Example #2
0
        public void SwitchedToView(IViewContent newView)
        {
            if (newView == null)
            {
                throw new ArgumentNullException("newView");
            }
            if (currentView == newView)
            {
                return;
            }
            if (currentView != null)
            {
                if (newView.SupportsSwitchToThisWithoutSaveLoad(this, currentView) ||
                    currentView.SupportsSwitchFromThisWithoutSaveLoad(this, newView))
                {
                    // switch without Save/Load
                    currentView.SwitchFromThisWithoutSaveLoad(this, newView);
                    newView.SwitchToThisWithoutSaveLoad(this, currentView);

                    currentView = newView;
                    return;
                }
            }
            if (currentView != null)
            {
                SaveCurrentView();
            }
            try
            {
                inLoadOperation = true;
                VelerSoftware.SZC.Debugger.Core.Properties memento = GetMemento(newView);
                using (Stream sourceStream = OpenRead())
                {
                    IViewContent oldView = currentView;
                    try
                    {
                        currentView = newView;
                        // don't reset fileData if the file is untitled, because OpenRead() wouldn't be able to read it otherwise
                        if (this.IsUntitled == false)
                        {
                            fileData = null;
                        }
                        newView.Load(this, sourceStream);
                    }
                    catch
                    {
                        // stay with old view in case of exceptions
                        currentView = oldView;
                        throw;
                    }
                }
                RestoreMemento(newView, memento);
            }
            finally
            {
                inLoadOperation = false;
            }
        }
Example #3
0
 private void ReloadFromDiskInternal()
 {
     fileData = null;
     if (currentView != null)
     {
         try
         {
             inLoadOperation = true;
             VelerSoftware.SZC.Debugger.Core.Properties memento = GetMemento(currentView);
             using (Stream sourceStream = OpenRead())
             {
                 currentView.Load(this, sourceStream);
             }
             IsDirty = false;
             RestoreMemento(currentView, memento);
         }
         finally
         {
             inLoadOperation = false;
         }
     }
 }