Exemple #1
0
        protected void SwitchedToView(IViewContent newView)
        {
            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;
                Properties memento = GetMemento(newView);
                using (Stream sourceStream = OpenRead()) {
                    currentView = newView;
                    fileData    = null;
                    newView.Load(this, sourceStream);
                }
                RestoreMemento(newView, memento);
            } finally {
                inLoadOperation = false;
            }
        }
		public override void SwitchFromThisWithoutSaveLoad(OpenedFile file, IViewContent newView)
		{
			if (file == this.PrimaryFile && this != newView) {
				SaveToPrimary();
				primaryViewContent.SwitchFromThisWithoutSaveLoad(file, newView);
			}
		}
Exemple #3
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;
            }
        }
        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;
                }
                SaveCurrentView();
            }
            try {
                inLoadOperation = true;
                Properties memento = GetMemento(newView);
                using (Stream sourceStream = OpenRead()) {
                    IViewContent oldView = currentView;
                    bool         success = false;
                    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);
                        success = true;
                    } finally {
                        // Use finally instead of catch+rethrow so that the debugger
                        // breaks at the original crash location.
                        if (!success)
                        {
                            // stay with old view in case of exceptions
                            currentView = oldView;
                        }
                    }
                }
                RestoreMemento(newView, memento);
            } finally {
                inLoadOperation = false;
            }
        }