예제 #1
0
        internal void AddDocument(IVisualStudioHostDocument document, bool isCurrentContext, bool hookupHandlers)
        {
            AssertIsForeground();

            // We do not want to allow message pumping/reentrancy when processing project system changes.
            using (Dispatcher.CurrentDispatcher.DisableProcessing())
            {
                lock (_gate)
                {
                    _documents.Add(document.Id, document);
                    _documentMonikers.Add(document.Key.Moniker, document);
                }

                if (_pushingChangesToWorkspaceHosts)
                {
                    this.ProjectTracker.NotifyWorkspaceHosts(host => host.OnDocumentAdded(document.GetInitialState()));

                    if (document.IsOpen)
                    {
                        this.ProjectTracker.NotifyWorkspaceHosts(host => host.OnDocumentOpened(document.Id, document.GetOpenTextBuffer(), isCurrentContext));
                    }
                }

                if (hookupHandlers)
                {
                    document.Opened += s_documentOpenedEventHandler;
                    document.Closing += s_documentClosingEventHandler;
                    document.UpdatedOnDisk += s_documentUpdatedOnDiskEventHandler;
                }

                DocumentProvider.NotifyDocumentRegisteredToProjectAndStartToRaiseEvents(document);

                if (!_pushingChangesToWorkspaceHosts && document.IsOpen)
                {
                    StartPushingToWorkspaceAndNotifyOfOpenDocuments();
                }
            }
        }
예제 #2
0
        internal void AddAdditionalDocument(IVisualStudioHostDocument document, bool isCurrentContext)
        {
            _additionalDocuments.Add(document.Id, document);
            _documentMonikers.Add(document.Key.Moniker, document);

            if (_pushingChangesToWorkspaceHosts)
            {
                this.ProjectTracker.NotifyWorkspaceHosts(host => host.OnAdditionalDocumentAdded(document.GetInitialState()));

                if (document.IsOpen)
                {
                    this.ProjectTracker.NotifyWorkspaceHosts(host => host.OnAdditionalDocumentOpened(document.Id, document.GetOpenTextBuffer(), isCurrentContext));
                }
            }

            document.Opened += s_additionalDocumentOpenedEventHandler;
            document.Closing += s_additionalDocumentClosingEventHandler;
            document.UpdatedOnDisk += s_additionalDocumentUpdatedOnDiskEventHandler;

            DocumentProvider.NotifyDocumentRegisteredToProject(document);

            if (!_pushingChangesToWorkspaceHosts && document.IsOpen)
            {
                StartPushingToWorkspaceAndNotifyOfOpenDocuments();
            }
        }
예제 #3
0
        internal void AddAdditionalDocument(IVisualStudioHostDocument document, bool isCurrentContext)
        {
            AssertIsForeground();

            lock (_gate)
            {
                _additionalDocuments.Add(document.Id, document);
                _documentMonikers.Add(document.Key.Moniker, document);
            }

            if (_pushingChangesToWorkspaceHosts)
            {
                this.ProjectTracker.NotifyWorkspaceHosts(host => host.OnAdditionalDocumentAdded(document.GetInitialState()));

                if (document.IsOpen)
                {
                    this.ProjectTracker.NotifyWorkspaceHosts(host => host.OnAdditionalDocumentOpened(document.Id, document.GetOpenTextBuffer(), isCurrentContext));
                }
            }

            DocumentProvider.NotifyDocumentRegisteredToProjectAndStartToRaiseEvents(document);

            if (!_pushingChangesToWorkspaceHosts && document.IsOpen)
            {
                StartPushingToWorkspaceAndNotifyOfOpenDocuments();
            }
        }
예제 #4
0
        internal void AddDocument(IVisualStudioHostDocument document, bool isCurrentContext)
        {
            // We do not want to allow message pumping/reentrancy when processing project system changes.
            using (Dispatcher.CurrentDispatcher.DisableProcessing())
            {
                if (_miscellaneousFilesWorkspaceOpt != null)
                {
                    _miscellaneousFilesWorkspaceOpt.OnFileIncludedInProject(document);
                }

                _documents.Add(document.Id, document);
                _documentMonikers.Add(document.Key.Moniker, document);

                if (_pushingChangesToWorkspaceHosts)
                {
                    this.ProjectTracker.NotifyWorkspaceHosts(host => host.OnDocumentAdded(document.GetInitialState()));

                    if (document.IsOpen)
                    {
                        this.ProjectTracker.NotifyWorkspaceHosts(host => host.OnDocumentOpened(document.Id, document.GetOpenTextBuffer(), isCurrentContext));
                    }
                }

                document.Opened += s_documentOpenedEventHandler;
                document.Closing += s_documentClosingEventHandler;
                document.UpdatedOnDisk += s_documentUpdatedOnDiskEventHandler;

                DocumentProvider.NotifyDocumentRegisteredToProject(document);

                if (!_pushingChangesToWorkspaceHosts && document.IsOpen)
                {
                    StartPushingToWorkspaceAndNotifyOfOpenDocuments();
                }
            }
        }