예제 #1
0
 public VSProcess GetVSProcessWithoutSolution()
 {
     VSProcess.Initialize(vsProcesses);
     foreach (var vsProcess in vsProcesses)
     {
         if (!vsProcess.HasOpenSolution)
         {
             return(vsProcess);
         }
     }
     return(null);
 }
예제 #2
0
 public VSProcess GetVSProcessWithSolution(string solutionFilePath)
 {
     VSProcess.Initialize(vsProcesses);
     foreach (var vsProcess in vsProcesses)
     {
         if (vsProcess.HasOpenSolution && vsProcess.Solution.FullName == solutionFilePath)
         {
             return(vsProcess);
         }
     }
     return(null);
 }
예제 #3
0
        public static void GetAllRunningInstances(ref List <VSProcess> runningVSInstances)
        {
            IDictionary <string, object> runningObjects = ProcessFinder.GetRunningObjectTables();

            foreach (string objectName in runningObjects.Keys)
            {
                if (objectName.StartsWith("!VisualStudio.DTE"))
                {
                    var vsProcess = VSProcess.FromROT(objectName, runningObjects[objectName]);
                    if (vsProcess != null)
                    {
                        runningVSInstances.Add(vsProcess);
                    }
                }
            }
        }
예제 #4
0
        public void PrintVSInstance(VSProcess vsProcess)
        {
            if (vsProcess == null || !vsProcess.IsInitialized)
            {
                return;
            }

            Console.WriteLine($"{vsProcess.ROTName}");

            if (vsProcess.HasOpenSolution)
            {
                Console.WriteLine($"\t{vsProcess.Solution.FullName}");
            }
            else
            {
                Console.WriteLine($"\tNo solution open");
            }
        }
예제 #5
0
        public static VSProcess GetInstanceByProcessId(int processId)
        {
            IDictionary <string, object> runningObjects = ProcessFinder.GetRunningObjectTables();

            foreach (string objectName in runningObjects.Keys)
            {
                if (objectName.StartsWith("!VisualStudio.DTE") && objectName.EndsWith($"{processId}"))
                {
                    var vsProcess = VSProcess.FromROT(objectName, runningObjects[objectName]);
                    if (vsProcess != null)
                    {
                        return(vsProcess);
                    }
                }
            }

            return(null);
        }
예제 #6
0
 public static void Initialize(VSProcess vsProcess)
 {
     vsProcess?.Initialize();
 }