/// <inheritdoc/> public IViewContent NewFile(string defaultName, byte[] content) { if (defaultName == null) { throw new ArgumentNullException("defaultName"); } if (content == null) { throw new ArgumentNullException("content"); } var displayBindingService = SD.DisplayBindingService; IDisplayBinding binding = displayBindingService.GetBindingPerFileName(FileName.Create(defaultName)); if (binding == null) { binding = new ErrorFallbackBinding("Can't create display binding for file " + defaultName); } OpenedFile file = CreateUntitledOpenedFile(defaultName, content); IViewContent newContent = binding.CreateContentForFile(file); if (newContent == null) { LoggingService.Warn("Created view content was null - DefaultName:" + defaultName); file.CloseIfAllViewsClosed(); return(null); } displayBindingService.AttachSubWindows(newContent, false); SD.Workbench.ShowView(newContent); return(newContent); }
public void Invoke(FileName fileName) { OpenedFile file = SD.FileService.GetOrCreateOpenedFile(fileName); try { IViewContent newContent = binding.CreateContentForFile(file); if (newContent != null) { SD.DisplayBindingService.AttachSubWindows(newContent, false); SD.Workbench.ShowView(newContent, switchToOpenedView); } } finally { file.CloseIfAllViewsClosed(); } }