public OpenDocumentViewModel(MainViewModel mainViewModel, DocumentViewModel document) { Document = document; MainViewModel = mainViewModel; NuGet = new NuGetDocumentViewModel(mainViewModel.NuGet); _dispatcher = Dispatcher.CurrentDispatcher; var roslynHost = mainViewModel.RoslynHost; IsDirty = document?.IsAutoSave == true; _workingDirectory = Document != null ? Path.GetDirectoryName(Document.Path) : MainViewModel.DocumentRoot.Path; Platform = Platform.X86; _executionHost = new ExecutionHost(GetHostExeName(), _workingDirectory, roslynHost.DefaultReferences.OfType <PortableExecutableReference>().Select(x => x.FilePath), roslynHost.DefaultImports, mainViewModel.NuGetConfiguration); SaveCommand = new DelegateCommand(() => Save(promptSave: false)); RunCommand = new DelegateCommand(Run, () => !IsRunning); CompileAndSaveCommand = new DelegateCommand(CompileAndSave); RestartHostCommand = new DelegateCommand(RestartHost); FormatDocumentCommand = new DelegateCommand(FormatDocument); CommentSelectionCommand = new DelegateCommand(() => CommentUncommentSelection(CommentAction.Comment)); UncommentSelectionCommand = new DelegateCommand(() => CommentUncommentSelection(CommentAction.Uncomment)); }
public OpenDocumentViewModel(IServiceLocator serviceLocator, MainViewModel mainViewModel, ICommandProvider commands) { _serviceLocator = serviceLocator; MainViewModel = mainViewModel; CommandProvider = commands; NuGet = serviceLocator.GetInstance <NuGetDocumentViewModel>(); _dispatcher = Dispatcher.CurrentDispatcher; var roslynHost = mainViewModel.RoslynHost; Platform = Platform.X86; _executionHost = new ExecutionHost(GetHostExeName(), _workingDirectory, roslynHost.DefaultReferences.OfType <PortableExecutableReference>().Select(x => x.FilePath), roslynHost.DefaultImports, mainViewModel.NuGetConfiguration); SaveCommand = commands.CreateAsync(() => Save(promptSave: false)); RunCommand = commands.CreateAsync(Run, () => !IsRunning); CompileAndSaveCommand = commands.CreateAsync(CompileAndSave); RestartHostCommand = commands.CreateAsync(RestartHost); FormatDocumentCommand = commands.CreateAsync(FormatDocument); CommentSelectionCommand = commands.CreateAsync(() => CommentUncommentSelection(CommentAction.Comment)); UncommentSelectionCommand = commands.CreateAsync(() => CommentUncommentSelection(CommentAction.Uncomment)); RenameSymbolCommand = commands.CreateAsync(RenameSymbol); }
public void Close() { _viewDisposable?.Dispose(); _executionHost?.Dispose(); _executionHost = null; }