コード例 #1
0
        private void NotifyDocChanged()
        {
            IVsHierarchy hierarchy;
            uint         itemID;
            IntPtr       docData;
            uint         docCookie = 0;

            if (_FileName.Length == 0)
            {
                return;
            }

            IVsRunningDocumentTable runningDocTable = (IVsRunningDocumentTable)GetService(
                typeof(SVsRunningDocumentTable));

            try
            {
                ErrorHandler.ThrowOnFailure(runningDocTable.FindAndLockDocument((uint)_VSRDTFLAGS.RDT_ReadLock,
                                                                                _FileName, out hierarchy, out itemID, out docData, out docCookie));

                ErrorHandler.ThrowOnFailure(runningDocTable.NotifyDocumentChanged(docCookie,
                                                                                  (uint)__VSRDTATTRIB.RDTA_DocDataReloaded));
            }
            finally
            {
                if (runningDocTable != null)
                {
                    ErrorHandler.ThrowOnFailure(runningDocTable.UnlockDocument((uint)_VSRDTFLAGS.RDT_ReadLock,
                                                                               docCookie));
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Gets an instance of the RunningDocumentTable (RDT) service which manages the set of currently open
        /// documents in the environment and then notifies the client that an open document has changed
        /// </summary>
        private void NotifyDocChanged()
        {
            // Make sure that we have a file name
            if (_fileName.Length == 0)
            {
                return;
            }

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

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

            ErrorHandler.ThrowOnFailure(hr);

            // Send the notification
            hr = runningDocTable.NotifyDocumentChanged(docCookie, (uint)__VSRDTATTRIB.RDTA_DocDataReloaded);

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

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

            /*
             * IVsFileChangeEx fileChange;
             * fileChange = GetService(typeof(SVsFileChangeEx)) as IVsFileChangeEx;
             *
             * if (fileChange != null)
             * {
             *
             *  ErrorHandler.ThrowOnFailure(fileChange.IgnoreFile(0, this.FileName, 1));
             *  if (docData != IntPtr.Zero)
             *  {
             *      IVsPersistDocData persistDocData = null;
             *
             *      // if interface is not supported, return null
             *      object unknown = Marshal.GetObjectForIUnknown(docData);
             *      if (unknown is IVsPersistDocData)
             *      {
             *          persistDocData = (IVsPersistDocData)unknown;
             *          if (persistDocData is IVsDocDataFileChangeControl)
             *          {
             *              _ManifestDesignerControl = (IVsDocDataFileChangeControl)persistDocData;
             *              if (_ManifestDesignerControl != null)
             *              {
             *                  ErrorHandler.ThrowOnFailure(_ManifestDesignerControl.IgnoreFileChanges(1));
             *              }
             *          }
             *      }
             *  }
             * }
             */
        }
コード例 #3
0
        /// <summary>
        /// Gets an instance of the RunningDocumentTable (RDT) service which manages the set of currently open
        /// documents in the environment and then notifies the client that an open document has changed
        /// </summary>
        private void NotifyDocChanged()
        {
            // Make sure that we have a file name
            if (fileName.Length == 0)
            {
                return;
            }

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

            uint         docCookie;
            IVsHierarchy hierarchy;
            uint         itemID;
            IntPtr       docData = IntPtr.Zero;

            try {
                // Lock the document
                int hr = runningDocTable.FindAndLockDocument(
                    (uint)_VSRDTFLAGS.RDT_ReadLock,
                    fileName,
                    out hierarchy,
                    out itemID,
                    out docData,
                    out docCookie
                    );

                ErrorHandler.ThrowOnFailure(hr);

                // Send the notification
                hr = runningDocTable.NotifyDocumentChanged(docCookie, (uint)__VSRDTATTRIB.RDTA_DocDataReloaded);

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

                // Check ff the call to NotifyDocChanged failed.
                ErrorHandler.ThrowOnFailure(hr);
            }
            finally
            {
                if (docData != IntPtr.Zero)
                {
                    Marshal.Release(docData);
                }
            }
        }