public RdtEntry(RunningDocumentInfo info) { Shell.ThreadHelper.ThrowIfNotOnUIThread(); Cookie = info.DocCookie; Moniker = info.Moniker; ReadLocks = info.ReadLocks; EditLocks = info.EditLocks; Flags = (RdtFlags)(int)info.Flags; ProjectId = info.ProjectGuid; if (info.IsDocumentInitialized) { if (info.DocData is IVsPersistDocData persist) { persist.IsDocDataDirty(out var isDirty); IsDirty = Convert.ToBoolean(isDirty); int hr = persist.GetGuidEditorType(out Guid editorType); if (ErrorHandler.Succeeded(hr)) { ClassId = editorType; } } if (info.DocData is IVsPersistDocData2 persist2) { persist2.IsDocDataReadOnly(out int isReadOnly); IsReadOnly = Convert.ToBoolean(isReadOnly); } } }
public int OnAfterFirstDocumentLock(VSCOOKIE cookie, uint lockType, uint readLocksRemaining, uint editLocksRemaining) { RdtFlags flags = (RdtFlags)(int)lockType; RdtEvent evt = MakeEvent(cookie, "OnAfterFirstDocumentLock: Lock Type={0}, Read Locks Remaining={1}, Edit Locks Remaining={2}", flags, readLocksRemaining, editLocksRemaining); _ds.RecordEvent(evt); // add this document to the data source if it's not there yet RdtEntry entry = _ds.FindEntry(cookie); if (entry == null) { RunningDocumentTable rdt = new RunningDocumentTable(); RunningDocumentInfo info = rdt.GetDocumentInfo(cookie); entry = new RdtEntry(info); _ds.Entries.Add(entry); } return(VSConstants.S_OK); }