Beispiel #1
0
    void adjustFileContext(ref fileContext ctx) {
      if (actCtx != null && (DateTime.UtcNow - actCtx.created).TotalMilliseconds < 300) return; //zivotnost ctx je omezena na jednu user akci
      IVsMonitorSelection monSel = (IVsMonitorSelection)GetService(typeof(SVsShellMonitorSelection));
      IntPtr hierPtr; uint currentItemId; IVsMultiItemSelect multSel; IntPtr selPtr;
      int hr = monSel.GetCurrentSelection(out hierPtr, out currentItemId, out multSel, out selPtr);
      if (multSel != null || hierPtr == null) return; //multi selection nebo zadna selection
      IVsHierarchy selectedHierarchy = Marshal.GetObjectForIUnknown(hierPtr) as IVsHierarchy;
      if (selectedHierarchy == null) return;

      string currentDocument;
      selectedHierarchy.GetCanonicalName(VSConstants.VSITEMID_ROOT, out currentDocument);
      selectedHierarchy.GetCanonicalName(currentItemId, out currentDocument);

      if (Machines._rootDir != null && currentDocument.IndexOf(Machines._rootDir) != 0) publisherCtx = null; //context je neaktualni

      if (publisherCtx == null) {
        string rootDoc;
        selectedHierarchy.GetCanonicalName(VSConstants.VSITEMID_ROOT, out rootDoc);
        publisherCtx = new publisherContext(rootDoc);
      }
      fileContext.adjustFileContext(currentDocument, new vsFileContext { hierarchy = selectedHierarchy, itemId = currentItemId }, publisherCtx, ref ctx);
    }
Beispiel #2
0
 public static void adjustFileContext(string fn, object vsNetHiearchy, publisherContext publ, ref fileContext ctx) {
   if (fn.EndsWith("\\")) { fn += "meta.xml"; if (!File.Exists(fn)) { ctx = null; return; } }
   fn = fn.ToLower();
   ctx = new fileContext(fn, vsNetHiearchy) { publ = publ };
 }