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 bool SupportsSwitchToThisWithoutSaveLoad(OpenedFile file, IViewContent oldView) { if (file == this.PrimaryFile) return oldView.SupportsSwitchToThisWithoutSaveLoad(file, primaryViewContent); else return base.SupportsSwitchFromThisWithoutSaveLoad(file, oldView); }
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; } }
public override bool SupportsSwitchFromThisWithoutSaveLoad(OpenedFile file, IViewContent newView) { if (file == this.PrimaryFile) { return(newView.SupportsSwitchToThisWithoutSaveLoad(file, primaryViewContent)); } else { return(base.SupportsSwitchFromThisWithoutSaveLoad(file, newView)); } }
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; } }
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 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; Properties memento = GetMemento(newView); using (Stream sourceStream = OpenRead()) { 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); } RestoreMemento(newView, memento); } finally { inLoadOperation = false; } }