src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/Editor/ProjectFileEditorPresenter.cs
/// <summary>
/// Called by anything attempting to open a project file editor window, usually by a command. This will show the window frame, creating it if
/// has not already been created.
/// </summary>
Called by anything attempting to open a project file editor window, usually by a command. This will show the window frame, creating it if
has not already been created.
Called by anything attempting to open a project file editor window usually by a command . This will show the window frame creating it if has not already been created .
public async Task OpenEditorAsync()
        {
            await _threadingService.SwitchToUIThread();
            lock (_lock)
            {
                if (_currentState != EditorState.NoEditor)
                {
                    _windowFrame?.Show();
                    return;
                }
                _currentState = EditorState.Initializing;
            }
            _textBufferManager = _textBufferManagerFactory.CreateExport().Value;
            await _textBufferManager.InitializeBufferAsync().ConfigureAwait(false);
            _windowFrame = await _shellHelper.OpenDocumentWithSpecificEditorAsync(_serviceProvider, _textBufferManager.FilePath, XmlFactoryGuid, Guid.Empty).ConfigureAwait(false);
            _textBufferStateListener = _textBufferListenerFactory.CreateExport().Value;
            await _textBufferStateListener.InitializeListenerAsync(_textBufferManager.FilePath).ConfigureAwait(false);
            _frameEventsListener = _frameEventsListenerFactory.CreateExport().Value;
            await _frameEventsListener.InitializeEventsAsync(_windowFrame).ConfigureAwait(false);
            _projectFileModelWatcher = _projectFileWatcherFactory.CreateExport().Value;
            _projectFileModelWatcher.InitializeModelWatcher();
            lock (_lock)
            {
                _currentState = EditorState.EditorOpen;
            }
        }
public async Task OpenEditorAsync ( ) { await _threadingService . SwitchToUIThread ( ) ; lock ( _lock ) { if ( _currentState != EditorState . NoEditor ) { _windowFrame ? . Show ( ) ; return ; } _currentState = EditorState . Initializing ; } _textBufferManager = _textBufferManagerFactory . CreateExport ( ) . Value ; await _textBufferManager . InitializeBufferAsync ( ) . ConfigureAwait ( false ) ; _windowFrame = await _shellHelper . OpenDocumentWithSpecificEditorAsync ( _serviceProvider , _textBufferManager . FilePath , XmlFactoryGuid , Guid . Empty ) . ConfigureAwait ( false ) ; _textBufferStateListener = _textBufferListenerFactory . CreateExport ( ) . Value ; await _textBufferStateListener . InitializeListenerAsync ( _textBufferManager . FilePath ) . ConfigureAwait ( false ) ; _frameEventsListener = _frameEventsListenerFactory . CreateExport ( ) . Value ; await _frameEventsListener . InitializeEventsAsync ( _windowFrame ) . ConfigureAwait ( false ) ; _projectFileModelWatcher = _projectFileWatcherFactory . CreateExport ( ) . Value ; _projectFileModelWatcher . InitializeModelWatcher ( ) ; lock ( _lock ) { _currentState = EditorState . EditorOpen ; } }
Called by anything attempting to open a project file editor window, usually by a command.
Called by anything attempting to open a project file editor window usually by a command .
// We access _windowFrame inside the lock, so we must be on the UI thread in that case // If the editor is already open, just show it and return // If we're initializing, _windowFrame might be null. In that case, when the initialization code // is done, it'll take care of showing the frame. // Set up the buffer manager, which will create the temp file. Nothing else in OpenEditor requires the UI thread (tasks aquire it as needed) // so we don't need to resume on the same thread. // Open and show the editor frame. // Set up the save listener // Set up the listener that will check for when the frame is closed. // Set up the project file watcher, so changes to the project file are detected and the buffer is updated. // Finally, move to the editor open state