コード例 #1
0
        public void NotifyChanges()
        {
            if (_serviceProvider == null)
            {
                return;
            }

            // Get a reference to the Running Document Table
            IVsRunningDocumentTable runningDocTable = (IVsRunningDocumentTable)_serviceProvider.GetService(typeof(SVsRunningDocumentTable));

            // Lock the document
            uint         docCookie;
            IVsHierarchy hierarchy;
            uint         itemID;
            IntPtr       docData;
            int          hr = runningDocTable.FindAndLockDocument(
                (uint)_VSRDTFLAGS.RDT_ReadLock,
                base.Name,
                out hierarchy,
                out itemID,
                out docData,
                out docCookie
                );

            ErrorHandler.ThrowOnFailure(hr);

            IVsUIShell shell = _serviceProvider.GetService(typeof(IVsUIShell)) as IVsUIShell;

            if (shell != null)
            {
                shell.UpdateDocDataIsDirtyFeedback(docCookie, (_dirty == true) ? 1 : 0);
            }

            // Unlock the document.
            // Note that we have to unlock the document even if the previous call failed.
            runningDocTable.UnlockDocument((uint)_VSRDTFLAGS.RDT_ReadLock, docCookie);

            // Check ff the call to NotifyDocChanged failed.
            //ErrorHandler.ThrowOnFailure(hr);
        }