Ejemplo n.º 1
0
        public void CallDeleteMarkedPackageDirectoriesOnSolutionOpen()
        {
            // Arrange
            uint solutionLoadedUICookie = 0x12;
            var mockVsMonitorSelection = new Mock<IVsMonitorSelection>();
            Guid solutionLoadedGuid = Microsoft.VisualStudio.VSConstants.UICONTEXT.SolutionExistsAndFullyLoaded_guid;
            mockVsMonitorSelection.Setup(m => m.GetCmdUIContextCookie(ref solutionLoadedGuid, out solutionLoadedUICookie));

            var solutionManager = new SolutionManager(GetMockDTE(), new Mock<IVsSolution>().Object, mockVsMonitorSelection.Object);
            var mockDeleteOnRestartManager = new Mock<IDeleteOnRestartManager>();
            solutionManager.DeleteOnRestartManager = new Lazy<IDeleteOnRestartManager>(() => mockDeleteOnRestartManager.Object);

            // Act
            solutionManager.OnCmdUIContextChanged(solutionLoadedUICookie, fActive: 1);

            // Assert
            mockDeleteOnRestartManager.Verify(m => m.DeleteMarkedPackageDirectories(), Times.Exactly(1));
        }
Ejemplo n.º 2
0
        private static void VisitProjects(IVsPackageManager packageManager, SolutionManager solutionManager, List <DGMLNode> nodes, List <DGMLLink> links)
        {
            foreach (var project in solutionManager.GetProjects())
            {
                var projectManager = packageManager.GetProjectManager(project);
                var repo           = projectManager.LocalRepository;
                if (!repo.GetPackages().Any())
                {
                    // Project has no packages. Ignore it.
                    continue;
                }
                // Project has packages. Add a node for it
                nodes.Add(new DGMLNode {
                    Name = project.GetCustomUniqueName(), Label = project.GetDisplayName(), Category = Resources.Visualizer_Project
                });

                var dependencies      = VisitProjectPackages(nodes, links, repo);
                var installedPackages = repo.GetPackages().Except(dependencies);
                links.AddRange(installedPackages.Select(c => new DGMLLink {
                    SourceName = project.GetCustomUniqueName(), DestName = c.GetFullName(), Category = Resources.Visualizer_InstalledPackage
                }));
            }
        }
        void Preprocess()
        {
            UseRemoteSourceOnly = ListAvailable.IsPresent || (!String.IsNullOrEmpty(Source) && !Updates.IsPresent);
            UseRemoteSource     = ListAvailable.IsPresent || Updates.IsPresent || !String.IsNullOrEmpty(Source);
            CollapseVersions    = !AllVersions.IsPresent;
            UpdateActiveSourceRepository(Source);

            Task.Run(async() => {
                // When ProjectName is not specified, get all of the projects in the solution
                if (string.IsNullOrEmpty(ProjectName))
                {
                    var projects = await SolutionManager.GetAllProjectsAsync();
                    DTEProjects  = projects.Select(project => (Project)project).ToList();
                }
                else
                {
                    await GetDTEProjectAsync(ProjectName);
                    DTEProjects = new List <Project> {
                        DTEProject
                    };
                }
            }).Wait();
        }
Ejemplo n.º 4
0
        private Tuple <IProjectManager, Project> GetProjectManager()
        {
            if (PackageManager == null)
            {
                return(null);
            }

            Project project = null;

            // If the user specified a project then use it
            if (!String.IsNullOrEmpty(ProjectName))
            {
                project = SolutionManager.GetProject(ProjectName);

                // If that project was invalid then throw
                if (project == null)
                {
                    ErrorHandler.ThrowNoCompatibleProjectsTerminatingError();
                }
            }
            else if (!String.IsNullOrEmpty(SolutionManager.DefaultProjectName))
            {
                // If there is a default project then use it
                project = SolutionManager.GetProject(SolutionManager.DefaultProjectName);

                Debug.Assert(project != null, "default project should never be invalid");
            }

            if (project == null)
            {
                // No project specified and default project was null
                return(null);
            }

            return(GetProjectManager(project));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Get the VsProject by ProjectName.
        /// If ProjectName is not specified, return the Default project of Tool window.
        /// </summary>
        /// <param name="throwIfNotExists"></param>
        /// <returns></returns>
        public VsProject GetProject(string projectName, bool throwIfNotExists)
        {
            VsProject project = null;

            // If the user does not specify a project then use the Default project
            if (String.IsNullOrEmpty(projectName))
            {
                projectName = SolutionManager.DefaultProjectName;
            }

            EnvDTE.Project dteProject = SolutionManager.GetProject(projectName);
            if (dteProject != null)
            {
                project = Solution.GetProject(dteProject);
            }

            // If that project was invalid then throw
            if (project == null && throwIfNotExists)
            {
                ErrorHandler.ThrowNoCompatibleProjectsTerminatingError();
            }

            return(project);
        }
Ejemplo n.º 6
0
    private void MoleculeActivation()
    {
        if (firstActivation)
        {
            atoms    = new GameObject[AtomsManager.GetN()];
            atoms[0] = AtomsManager.GetPivot();

            for (int i = 0; i < AtomsManager.GetAtoms().Count; i++)
            {
                atoms[i + 1] = AtomsManager.GetAtoms()[i].gameObject;
            }

            solutionAtoms    = new GameObject[AtomsManager.GetN()];
            solutionAtoms[0] = SolutionManager.GetPivot();

            for (int i = 0; i < SolutionManager.GetAtoms().Count; i++)
            {
                solutionAtoms[i + 1] = SolutionManager.GetAtoms()[i].gameObject;
            }

            CreateSolutionMST();
            atomsMST = VertexListToAdjencyList(solutionMST);
            Dfs(solutionMST[0]);

            DisplayMoleculeBonds();
            // IMPOSTA PARENTELE MOLECOLE
            ParentingMolecule();
            firstActivation = false;
        }
        else
        {
            Debug.Log("second");
            Dfs(solutionMST[0]);
            DisplayMoleculeBonds();
        }
    }
Ejemplo n.º 7
0
        //For debugging purpose only
        //[TestMethod]
        public void Test_ApplyBoundaryConditions_When_DimensionIsNotGreaterThan2TimesBandwidth()
        {
            /*
             * Созданная матрица:
             *
             * 1 2 3   2 3 4   3 4 5   0 0 0   0 0 0
             * 0 4 5   0 5 6   0 6 7   0 0 0   0 0 0
             * 0 0 6   0 0 7   0 0 8   0 0 0   0 0 0
             *
             * = = =   3 4 5   4 5 6   5 6 7   0 0 0
             * = = =   0 6 7   0 7 8   0 8 9   0 0 0
             * = = =   0 0 8   0 0 9   0 0 10  0 0 0
             *
             * = = =   = = =   5 6 7   6 7 8   7 8  9
             * = = =   = = =   0 8 9   0 9 10  0 10 11
             * = = =   = = =   0 0 10  0 0 11  0 0  12
             *
             * = = =   = = =   = = =   7 8  9   8 9  10
             * = = =   = = =   = = =   0 10 11  0 11 12
             * = = =   = = =   = = =   0 0  12  0 0  13
             *
             * = = =   = = =   = = =   = = =    9 10 11
             * = = =   = = =   = = =   = = =    0 12 13
             * = = =   = = =   = = =   = = =    0 0  14
             *
             * Правая часть:
             * 0 0 10
             *
             * 0 0 10
             *
             * 0 0 10
             *
             * 0 0 10
             *
             * 0 0 10
             *
             * Ожидаемый результат:
             *
             * Матрица:
             * 1 2 3   0 0 0   0 0 0   0 0 0   0 0 0
             * 0 4 5   0 0 0   0 0 0   0 0 0   0 0 0
             * 0 0 6   0 0 0   0 0 0   0 0 0   0 0 0
             *
             * = = =   3 0 0   0 0 0   0 0 0   0 0 0
             * = = =   0 6 0   0 0 0   0 0 0   0 0 0
             * = = =   0 0 8   0 0 0   0 0 0   0 0 0
             *
             * = = =   = = =   5 0 0   0 0 0   0 0 0
             * = = =   = = =   0 8 0   0 0 0   0 0 0
             * = = =   = = =   0 0 10  0 0 0   0 0 0
             *
             * = = =   = = =   = = =   7 0  0   0 0 0
             * = = =   = = =   = = =   0 10 0   0 0 0
             * = = =   = = =   = = =   0 0  12  0 0 0
             *
             * = = =   = = =   = = =   = = =    9 10 11
             * = = =   = = =   = = =   = = =    0 12 13
             * = = =   = = =   = = =   = = =    0 0  14
             *
             * Правая часть:
             * 0 0 10
             *
             * 0 0 0
             *
             * 0 0 0
             *
             * 0 0 0
             *
             * 0 0 10
             *
             */

            int dimension = 5;
            int bandWidth = 3;

            // Создаем глобальную матрицу
            SymmetricMatrix <MatrixDimension3> globalMatrix = new SymmetricMatrix <MatrixDimension3>(dimension, new MatrixDimension3());

            for (int row = 0; row < dimension; row++)
            {
                int rightBound = row + bandWidth < dimension ? row + bandWidth : dimension;
                for (int column = row; column < rightBound; column++)
                {
                    MatrixDimension3 matrixDim3 = new MatrixDimension3();
                    matrixDim3[0, 0] = row + column + 1;
                    matrixDim3[0, 1] = row + column + 2;
                    matrixDim3[0, 2] = row + column + 3;
                    matrixDim3[1, 1] = row + column + 4;
                    matrixDim3[1, 2] = row + column + 5;
                    matrixDim3[2, 2] = row + column + 6;

                    globalMatrix.setElement(row, column, matrixDim3);
                }
            }
            // Задаем граничные условия
            int[] boundaryConditions = { 1, 2, 3 };
            int   boundaryCount      = boundaryConditions.Count();

            // Задаем правую часть
            Vector3D rightPart = new Vector3D();

            rightPart.X = 0;
            rightPart.Y = 0;
            rightPart.Z = 10;
            List <Vector3D> rightSide = new List <Vector3D>();

            for (int count = 0; count < dimension; count++)
            {
                rightSide.Insert(count, rightPart);
            }

            // Учитываем граничные условия
            SolutionManager solution = new SolutionManager();
            //solution.applyBoundaryConditions(globalMatrix, rightSide, boundaryConditions);


            // Задаем ожидаемый результат
            Vector3D        neitralVector = new Vector3D();
            List <Vector3D> expectVector  = new List <Vector3D>();

            expectVector.Insert(0, rightPart);
            expectVector.Insert(1, neitralVector);
            expectVector.Insert(2, neitralVector);
            expectVector.Insert(3, neitralVector);
            expectVector.Insert(4, rightPart);

            MatrixDimension3 neitralMatrix = new MatrixDimension3();
            MatrixDimension3 expmatrixDim3 = new MatrixDimension3();
            SymmetricMatrix <MatrixDimension3> expectMatrix = new SymmetricMatrix <MatrixDimension3>(dimension, new MatrixDimension3());

            expmatrixDim3[0, 0] = 1;
            expmatrixDim3[0, 1] = 2;
            expmatrixDim3[0, 2] = 3;
            expmatrixDim3[1, 1] = 4;
            expmatrixDim3[1, 2] = 5;
            expmatrixDim3[2, 2] = 6;
            expectMatrix.setElement(0, 0, expmatrixDim3);

            //expectMatrix.setElement(0, 1, neitralMatrix);
            //expectMatrix.setElement(0, 2, neitralMatrix);
            //expectMatrix.setElement(1, 2, neitralMatrix);

            MatrixDimension3 expmatrixDim3_1 = new MatrixDimension3();

            expmatrixDim3_1[0, 0] = 3;
            expmatrixDim3_1[1, 1] = 6;
            expmatrixDim3_1[2, 2] = 8;
            expectMatrix.setElement(1, 1, expmatrixDim3_1);

            MatrixDimension3 expmatrixDim3_2 = new MatrixDimension3();

            expmatrixDim3_2[0, 0] = 5;
            expmatrixDim3_2[1, 1] = 8;
            expmatrixDim3_2[2, 2] = 10;
            expectMatrix.setElement(2, 2, expmatrixDim3_2);

            MatrixDimension3 expmatrixDim3_3 = new MatrixDimension3();

            expmatrixDim3_3[0, 0] = 7;
            expmatrixDim3_3[1, 1] = 10;
            expmatrixDim3_3[2, 2] = 12;
            expectMatrix.setElement(3, 3, expmatrixDim3_3);

            MatrixDimension3 expmatrixDim3_4 = new MatrixDimension3();

            expmatrixDim3_4[0, 0] = 9;
            expmatrixDim3_4[0, 1] = 10;
            expmatrixDim3_4[0, 2] = 11;
            expmatrixDim3_4[1, 1] = 12;
            expmatrixDim3_4[1, 2] = 13;
            expmatrixDim3_4[2, 2] = 14;
            expectMatrix.setElement(4, 4, expmatrixDim3_4);

            // Проверка
            foreach (Vector3D vector in rightSide)
            {
                Console.Write(vector.ToString() + " ");
            }
            Console.WriteLine();
            foreach (Vector3D vector in expectVector)
            {
                Console.Write(vector.ToString() + " ");
            }
            Console.WriteLine();

            Assert.IsTrue(expectMatrix.Equals(globalMatrix), "All is bad");
        }
 protected Task <EnvDTE.Project> GetDefaultProjectAsync()
 {
     return(SolutionManager.GetDefaultProjectAsync());
 }
 /// <summary>
 /// Returns the mill resources
 /// </summary>
 /// <returns>returns the static mill resources</returns>
 public Resource getResources()
 {
     return(SolutionManager.GetResource());
 }
Ejemplo n.º 10
0
        public async Task Run(ReferencesOptions no)
        {
            if (string.IsNullOrWhiteSpace(no.RootPath))
            {
                no.RootPath = Directory.GetCurrentDirectory();
            }
            if (!Directory.Exists(no.RootPath))
            {
                ConsoleEx.WriteErrorLine($"Path {no.RootPath} not exists");
                return;
            }

            var sm      = new SolutionManager(null);
            var results = sm.FindAllReferences(no.RootPath, no.SourceProject, no.ClassName);

            if (no.IsTableView)
            {
                var result = await results.ToListAsync();

                var headerThickness = new LineThickness(LineWidth.Double, LineWidth.Single);
                var doc             = new Document(new Span(no.ClassName)
                {
                    Color = Yellow
                }, "\n",
                                                   new Grid
                {
                    Color    = Gray,
                    Columns  = { GridLength.Star(1), GridLength.Auto, GridLength.Auto, GridLength.Auto, GridLength.Auto, GridLength.Auto },
                    Children =
                    {
                        new Cell("Project")
                        {
                            Stroke = headerThickness
                        },
                        new Cell("File")
                        {
                            Stroke = headerThickness
                        },
                        new Cell("Block")
                        {
                            Stroke = headerThickness
                        },
                        new Cell("Namespace")
                        {
                            Stroke = headerThickness
                        },
                        new Cell("Class")
                        {
                            Stroke = headerThickness
                        },
                        new Cell("Line")
                        {
                            Stroke = headerThickness
                        },
                        result.Select(item => new[]
                        {
                            new Cell(item.ProjectName),
                            new Cell(item.FileName),
                            new Cell(item.Block),
                            new Cell(item.Namespace),
                            new Cell(item.ClassName),
                            new Cell(item.LineNumber),
                        })
                    }
                }
                                                   );

                ConsoleRenderer.RenderDocument(doc);
            }
            else
            {
                await foreach (var r in results)
                {
                    ConsoleEx.WriteOKLine($"{r.ProjectName} [{r.FileName}->{r.Namespace}.{r.ClassName}:{r.LineNumber}]");
                }
            }
        }
Ejemplo n.º 11
0
        private async Task <IVsWindowFrame> CreateDocWindowForSolutionAsync()
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            IVsWindowFrame windowFrame = null;
            var            solution    = await this.GetServiceAsync <IVsSolution>();

            var uiShell = await this.GetServiceAsync <SVsUIShell, IVsUIShell>();

            var windowFlags =
                (uint)_VSRDTFLAGS.RDT_DontAddToMRU |
                (uint)_VSRDTFLAGS.RDT_DontSaveAs;

            if (!await SolutionManager.IsSolutionAvailableAsync())
            {
                throw new InvalidOperationException(Resources.SolutionIsNotSaved);
            }

            var projects = await SolutionManager.GetNuGetProjectsAsync();

            if (!projects.Any())
            {
                // NOTE: The menu 'Manage NuGet Packages For Solution' will be disabled in this case.
                // But, it is possible, that, before NuGetPackage is loaded in VS, the menu is enabled and used.
                // For once, this message will be shown. Once the package is loaded, the menu will get disabled as appropriate
                MessageHelper.ShowWarningMessage(Resources.NoSupportedProjectsInSolution, Resources.ErrorDialogBoxTitle);
                return(null);
            }

            // load packages.config. This makes sure that an exception will get thrown if there
            // are problems with packages.config, such as duplicate packages. When an exception
            // is thrown, an error dialog will pop up and this doc window will not be created.
            foreach (var project in projects)
            {
                await project.GetInstalledPackagesAsync(CancellationToken.None);
            }

            var uiController = UIFactory.Create(projects.ToArray());

            var solutionName = (string)_dte.Solution.Properties.Item("Name").Value;

            var model = new PackageManagerModel(
                uiController,
                isSolution: true,
                editorFactoryGuid: GuidList.guidNuGetEditorType)
            {
                SolutionName = solutionName
            };

            var vsWindowSearchHostfactory = await GetServiceAsync(typeof(SVsWindowSearchHostFactory)) as IVsWindowSearchHostFactory;

            var vsShell = await GetServiceAsync(typeof(SVsShell)) as IVsShell4;

            var control        = new PackageManagerControl(model, Settings.Value, vsWindowSearchHostfactory, vsShell, OutputConsoleLogger);
            var windowPane     = new PackageManagerWindowPane(control);
            var guidEditorType = GuidList.guidNuGetEditorType;
            var guidCommandUI  = Guid.Empty;
            var caption        = Resx.Label_SolutionNuGetWindowCaption;
            var documentName   = _dte.Solution.FullName;

            var ppunkDocView = IntPtr.Zero;
            var ppunkDocData = IntPtr.Zero;
            var hr           = 0;

            try
            {
                ppunkDocView = Marshal.GetIUnknownForObject(windowPane);
                ppunkDocData = Marshal.GetIUnknownForObject(model);
                hr           = uiShell.CreateDocumentWindow(
                    windowFlags,
                    documentName,
                    (IVsUIHierarchy)solution,
                    (uint)VSConstants.VSITEMID.Root,
                    ppunkDocView,
                    ppunkDocData,
                    ref guidEditorType,
                    null,
                    ref guidCommandUI,
                    null,
                    caption,
                    string.Empty,
                    null,
                    out windowFrame);
            }
            finally
            {
                if (ppunkDocView != IntPtr.Zero)
                {
                    Marshal.Release(ppunkDocData);
                }

                if (ppunkDocData != IntPtr.Zero)
                {
                    Marshal.Release(ppunkDocView);
                }
            }

            ErrorHandler.ThrowOnFailure(hr);
            return(windowFrame);
        }
Ejemplo n.º 12
0
 public void CloseSolution()
 {
     this.TheSolution = null;
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Method gets deployment instance record
        /// </summary>
        /// <param name="serviceProxy">organization service proxy</param>
        /// <param name="solutionFile">solution file info</param>
        private void ImportSolutionToTargetInstance(OrganizationServiceProxy serviceProxy, SolutionFileInfo solutionFile)
        {
            Entity           sourceControl      = solutionFile.Solution;
            EntityCollection deploymentInstance = this.FetchDeplopymentInstance(serviceProxy, sourceControl.Id);
            var checkTarget = false;

            if (deploymentInstance.Entities.Count > 0)
            {
                foreach (Entity instance in deploymentInstance.Entities)
                {
                    ClientCredentials clientCredentials = new ClientCredentials();
                    clientCredentials.UserName.UserName = instance.Attributes["syed_name"].ToString();
                    clientCredentials.UserName.Password = this.DecryptString(instance.Attributes["syed_password"].ToString());
                    ////Resetting password
                    instance.Attributes["syed_password"] = "******";
                    serviceProxy.Update(instance);
                    OrganizationServiceProxy targetserviceProxy = new OrganizationServiceProxy(new Uri(instance.Attributes["syed_instanceurl"].ToString()), null, clientCredentials, null);
                    targetserviceProxy.EnableProxyTypes();
                    List <EntityCollection> componentDependency = this.GetDependentComponents(serviceProxy, new Guid(solutionFile.MasterSolutionId), solutionFile.SolutionUniqueName);

                    SolutionManager sol = new SolutionManager(serviceProxy);

                    Singleton.SolutionFileInfoInstance.WebJobsLog.Append("<br><br><table cellpadding='5' cellspacing='0' style='border: 1px solid #ccc;font-size: 9pt;font-family:Arial'><tr><th style='background-color: #B8DBFD;border: 1px solid #ccc'>Dependent Components in Source Instance</th><th style='background-color: #B8DBFD;border: 1px solid #ccc'>Required Components</th></tr>");

                    if (componentDependency.Count > 0)
                    {
                        foreach (var comDependency in componentDependency)
                        {
                            if (comDependency != null && comDependency.Entities != null && comDependency.Entities.Count > 0)
                            {
                                foreach (Entity dependency in comDependency.Entities)
                                {
                                    Singleton.SolutionFileInfoInstance.WebJobsLog.Append("<tr>");
                                    Singleton.SolutionFileInfoInstance.WebJobsLog.Append("<td style='width:100px;background-color:#FFCC99;border: 1px solid #ccc'>");
                                    sol.GetComponentDetails(null, null, dependency, ((OptionSetValue)dependency.Attributes["dependentcomponenttype"]).Value, (Guid)dependency.Attributes["dependentcomponentobjectid"], "dependentcomponenttype", null);
                                    Singleton.SolutionFileInfoInstance.WebJobsLog.Append("</td>");
                                    Singleton.SolutionFileInfoInstance.WebJobsLog.Append("<td style='width:100px;background-color:#FFCC99;border: 1px solid #ccc'>");
                                    sol.GetComponentDetails(null, null, dependency, ((OptionSetValue)dependency.Attributes["requiredcomponenttype"]).Value, (Guid)dependency.Attributes["requiredcomponentobjectid"], "requiredcomponenttype", null);
                                    Singleton.SolutionFileInfoInstance.WebJobsLog.Append("</td>");
                                    Singleton.SolutionFileInfoInstance.WebJobsLog.Append("</tr>");
                                }
                            }
                        }
                    }
                    else
                    {
                        Singleton.SolutionFileInfoInstance.WebJobsLog.Append("<tr>");
                        Singleton.SolutionFileInfoInstance.WebJobsLog.Append("<td style='width:100px;background-color:#FFCC99;border: 1px solid #ccc'>");
                        Singleton.SolutionFileInfoInstance.WebJobsLog.Append("There is no missing dependent component to display");
                        Singleton.SolutionFileInfoInstance.WebJobsLog.Append("</td>");
                        Singleton.SolutionFileInfoInstance.WebJobsLog.Append("<td style='width:100px;background-color:#FFCC99;border: 1px solid #ccc'>");
                        Singleton.SolutionFileInfoInstance.WebJobsLog.Append("----");
                        Singleton.SolutionFileInfoInstance.WebJobsLog.Append("</td>");
                        Singleton.SolutionFileInfoInstance.WebJobsLog.Append("</tr>");
                    }

                    Singleton.SolutionFileInfoInstance.WebJobsLog.Append("</table><br><br>");
                    Singleton.SolutionFileInfoInstance.WebJobsLog.Append("<table cellpadding='5' cellspacing='0' style='border: 1px solid #ccc;font-size: 9pt;font-family:Arial'><tr><th style='background-color: #B8DBFD;border: 1px solid #ccc'> Missing Dependent Components in Target Instance</th><th style='background-color: #B8DBFD;border: 1px solid #ccc'>Components Details</th></tr>");

                    if (componentDependency.Count > 0)
                    {
                        foreach (var comDependency in componentDependency)
                        {
                            checkTarget = this.CheckDependency(targetserviceProxy, comDependency, sol, checkTarget, serviceProxy);
                        }
                    }

                    if (!checkTarget)
                    {
                        Singleton.SolutionFileInfoInstance.WebJobsLog.Append("<tr>");
                        Singleton.SolutionFileInfoInstance.WebJobsLog.Append("<td style='width:100px;background-color:tomato;border: 1px solid #ccc'>");
                        Singleton.SolutionFileInfoInstance.WebJobsLog.Append("All dependent components are present in target instance");
                        Singleton.SolutionFileInfoInstance.WebJobsLog.Append("</td>");
                        Singleton.SolutionFileInfoInstance.WebJobsLog.Append("<td style='width:100px;background-color:tomato;border: 1px solid #ccc'>");
                        Singleton.SolutionFileInfoInstance.WebJobsLog.Append("----");
                        Singleton.SolutionFileInfoInstance.WebJobsLog.Append("</td>");
                        Singleton.SolutionFileInfoInstance.WebJobsLog.Append("</tr>");
                        Singleton.SolutionFileInfoInstance.WebJobsLog.Append("</table><br><br>");
                        this.ImportSolution(targetserviceProxy, solutionFile, new Uri(instance.Attributes["syed_instanceurl"].ToString()));
                    }
                    else
                    {
                        Singleton.SolutionFileInfoInstance.WebJobsLog.AppendLine(" Target Instance missing Required components.  <br> ");
                        solutionFile.Solution[Constants.SourceControlQueueAttributeNameForStatus] = Constants.SourceControlQueueMissingComponents;
                        solutionFile.Solution["syed_webjobs"] = Singleton.SolutionFileInfoInstance.WebJobs();
                        Singleton.SolutionFileInfoInstance.UploadFiletoDynamics(serviceProxy, solutionFile.Solution);
                        solutionFile.Update();
                    }
                }
            }
        }
Ejemplo n.º 14
0
 /// <inheritdoc />
 protected override void Dispose(bool disposing)
 {
     _solutionManager?.Dispose();
     _solutionManager = null;
     base.Dispose(disposing);
 }
 private void Start()
 {
     atomFather          = transform.parent;
     solutionManager     = FindObjectOfType <SolutionManager>();
     centralCellSolution = FindObjectOfType <CentralCellSolution>();
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Initializes the package right after it's been "sited" into the fully-initialized Visual Studio IDE.
        /// </summary>
        protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            Logging.WriteLine("Initializing UnrealVS extension...");

            await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            // Grab the MenuCommandService
            MenuCommandService = await GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService;

            // Get access to Visual Studio's DTE object.  This object has various hooks into the Visual Studio
            // shell that are useful for writing extensions.
            DTE = await GetServiceAsync(typeof(DTE)) as DTE;

            Logging.WriteLine("DTE version " + DTE.Version);

            // Get selection manager and register to receive events
            SelectionManager =
                await GetServiceAsync(typeof(SVsShellMonitorSelection)) as IVsMonitorSelection;

            SelectionManager.AdviseSelectionEvents(this, out SelectionEventsHandle);

            // Get solution and register to receive events
            SolutionManager = await GetServiceAsync(typeof(SVsSolution)) as IVsSolution2;

            UpdateUnrealLoadedStatus();
            SolutionManager.AdviseSolutionEvents(this, out SolutionEventsHandle);

            // Grab the solution build manager.  We need this in order to change certain things about the Visual
            // Studio environment, like what the active startup project is
            // Get solution build manager
            SolutionBuildManager =
                await GetServiceAsync(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager2;

            SolutionBuildManager.AdviseUpdateSolutionEvents(this, out UpdateSolutionEventsHandle);

            // Create our command-line editor
            CommandLineEditor.Initialize();

            // Create our startup project selector
            StartupProjectSelector = new StartupProjectSelector();

            // Create 'BuildStartupProject' instance
            BuildStartupProject = new BuildStartupProject();

            // Create 'CompileSingleFile' instance
            CompileSingleFile = new CompileSingleFile();

            // Create 'GenerateProjectFiles' tools
            GenerateProjectFiles = new GenerateProjectFiles();

            // Create Batch Builder tools
            BatchBuilder.Initialize();

            // Create the project menu quick builder
            QuickBuilder = new QuickBuild();

            // Call parent implementation
            base.Initialize();

            if (DTE.Solution.IsOpen)
            {
                StartTicker();
            }
        }
Ejemplo n.º 17
0
        public async Task Run(NugetOptions no)
        {
            if (string.IsNullOrWhiteSpace(no.RootPath))
            {
                no.RootPath = Directory.GetCurrentDirectory();
            }
            if (!Directory.Exists(no.RootPath))
            {
                ConsoleEx.WriteErrorLine($"Path {no.RootPath} not exists");
                return;
            }

            var sm = new SolutionManager(null);

            var projects = new List <ProjectDetails>();

            await foreach (var solution in sm.FindSolutions(no.RootPath))
            {
                projects.AddRange(await sm.ReadSolution(solution));
            }

            var nugets = projects.Distinct().SelectMany(p => p.Nugets.Select(n => new
            {
                Name    = n.Name,
                Version = n.Version,
                Project = p.Name
            }));

            if (no.IgnoreSystemNugets)
            {
                nugets = nugets.Where(x => !x.Name.IsSystemNuget());
            }

            var grouped = nugets.GroupBy(n => n.Name).OrderBy(n => n.Key).Select(nuget => new NugetGroup
            {
                Min   = nuget.Min(n => n.Version),
                Max   = nuget.Max(n => n.Version),
                Count = nuget.Count(),
                Name  = nuget.Key
            });

            if (no.OnlyDiff)
            {
                grouped = grouped.Where(x => x.Min != x.Max);
            }

            var headerThickness = new LineThickness(LineWidth.Double, LineWidth.Single);

            var doc = new Document(new Span("Nugets:")
            {
                Color = Yellow
            }, "\n",
                                   new Grid
            {
                Color    = Gray,
                Columns  = { GridLength.Star(1), GridLength.Auto, GridLength.Auto, GridLength.Auto },
                Children =
                {
                    new Cell("Name")
                    {
                        Stroke = headerThickness
                    },
                    new Cell("Min")
                    {
                        Stroke = headerThickness
                    },
                    new Cell("Max")
                    {
                        Stroke = headerThickness
                    },
                    new Cell("Count")
                    {
                        Stroke = headerThickness
                    },
                    grouped.Select(item => new[]
                    {
                        new Cell(item.Name)
                        {
                            Color = ColumnColor(item)
                        },
                        new Cell(item.Min)
                        {
                            Color = ColumnColor(item)
                        },
                        new Cell(item.Max)
                        {
                            Color = ColumnColor(item)
                        },
                        new Cell(item.Count)
                        {
                            Color = ColumnColor(item)
                        },
                    })
                }
            }
                                   );

            ConsoleRenderer.RenderDocument(doc);
        }
Ejemplo n.º 18
0
        public async Task Run(SolutionOptions so)
        {
            if (string.IsNullOrWhiteSpace(so.RootPath))
            {
                so.RootPath = Directory.GetCurrentDirectory();
            }

            if (!Directory.Exists(so.RootPath))
            {
                ConsoleEx.WriteErrorLine($"Path {so.RootPath} not exists");
                return;
            }

            var sm        = new SolutionManager(null);
            var solutions = sm.FindSolutions(so.RootPath);

            int i = 0;

            await foreach (var s in solutions)
            {
                bool solution = false;

                if (so.ListProjects || so.ListNugets)
                {
                    var projects = await sm.ReadSolution(s);

                    foreach (var p in projects)
                    {
                        if ((so.ShowOnlyCore && !p.IsNetCore) || (so.ShowOnlyFull && p.IsNetCore))
                        {
                            continue;
                        }

                        if (!string.IsNullOrWhiteSpace(so.ProjectName) && p.Name.IndexOf(so.ProjectName.Trim(), System.StringComparison.InvariantCultureIgnoreCase) == -1)
                        {
                            continue;
                        }

                        if (so.ListProjects)
                        {
                            if (!solution)
                            {
                                solution = true;
                                ConsoleEx.WriteOKLine($"{i}. {s}");
                            }

                            ConsoleEx.WriteTitleLine($"  - {p.Name}");
                        }
                        else if (so.ListNugets)
                        {
                            bool project = false;

                            foreach (var n in p.Nugets)
                            {
                                if (so.IgnoreSystemNugets && n.Name.IsSystemNuget())
                                {
                                    continue;
                                }

                                if (!string.IsNullOrWhiteSpace(so.NugetName) && n.Name.IndexOf(so.NugetName.Trim(), System.StringComparison.InvariantCultureIgnoreCase) == -1)
                                {
                                    continue;
                                }

                                if (!solution)
                                {
                                    solution = true;
                                    ConsoleEx.WriteOKLine($"{i}. {s}");
                                }
                                if (!project)
                                {
                                    project = true;
                                    ConsoleEx.WriteTitleLine($"  - {p.Name}");
                                }
                                ConsoleEx.WriteDebugLine($"    - {n.Name} [{n.Version}]");
                            }
                        }
                    }
                }
                i++;
            }
        }
Ejemplo n.º 19
0
 static void Main(string[] args)
 {
     var x = new SolutionManager();
     x.GoToLevel(30);
 }
Ejemplo n.º 20
0
 public void SetSolutionManager(SolutionManager sm)
 {
     solutionManager = sm;
 }
Ejemplo n.º 21
0
        /// <summary>
        /// Method merges solution
        /// </summary>
        /// <param name="solutionFileInfo">solution file info</param>
        /// <param name="organizationServiceProxy">organization service proxy</param>
        private void MergeSolutions(SolutionFileInfo solutionFileInfo, OrganizationServiceProxy organizationServiceProxy)
        {
            SolutionManager solutionManager = new SolutionManager(organizationServiceProxy);

            solutionManager.CopyComponents(solutionFileInfo);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Method checks dependency components present in target instance
        /// </summary>
        /// <param name="serviceProxy">service proxy</param>
        /// <param name="dependencyComponents">dependency components</param>
        /// <param name="solutionManager">solution manager</param>
        /// <param name="checkTarget">check target</param>
        /// <param name="sourceServiceProxy">source service proxy</param>
        /// <returns>returns boolean value</returns>
        private bool CheckDependency(OrganizationServiceProxy serviceProxy, EntityCollection dependencyComponents, SolutionManager solutionManager, bool checkTarget, OrganizationServiceProxy sourceServiceProxy)
        {
            foreach (Entity component in dependencyComponents.Entities)
            {
                try
                {
                    solutionManager.GetComponentDetails(null, null, component, ((OptionSetValue)component.Attributes["requiredcomponenttype"]).Value, (Guid)component.Attributes["requiredcomponentobjectid"], "requiredcomponenttype", serviceProxy);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    Singleton.SolutionFileInfoInstance.WebJobsLog.Append("<tr>");
                    Singleton.SolutionFileInfoInstance.WebJobsLog.Append("<td style='width:100px;background-color:tomato;border: 1px solid #ccc'>");
                    Console.WriteLine("The below component was not present in Target");
                    solutionManager.GetComponentDetails(null, null, component, ((OptionSetValue)component.Attributes["dependentcomponenttype"]).Value, (Guid)component.Attributes["dependentcomponentobjectid"], "dependentcomponenttype", null);
                    Singleton.SolutionFileInfoInstance.WebJobsLog.Append("</td>");
                    Singleton.SolutionFileInfoInstance.WebJobsLog.Append("<td style='width:100px;background-color:tomato;border: 1px solid #ccc'>");
                    solutionManager.GetComponentDetails(null, null, component, ((OptionSetValue)component.Attributes["requiredcomponenttype"]).Value, (Guid)component.Attributes["requiredcomponentobjectid"], "requiredcomponenttype", null);
                    Singleton.SolutionFileInfoInstance.WebJobsLog.Append("</td>");
                    Singleton.SolutionFileInfoInstance.WebJobsLog.Append("</tr>");
                    checkTarget = true;
                }
            }

            return(checkTarget);
        }
 internal DatabrickExporter(SolutionManager manager)
 {
     Manager = manager;
 }
Ejemplo n.º 24
0
        private async Task <IVsWindowFrame> CreateDocWindowAsync(
            Project project,
            string documentName,
            IVsHierarchy hier,
            uint itemId)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            var windowFlags =
                (uint)_VSRDTFLAGS.RDT_DontAddToMRU |
                (uint)_VSRDTFLAGS.RDT_DontSaveAs;

            if (!await SolutionManager.IsSolutionAvailableAsync())
            {
                throw new InvalidOperationException(Resources.SolutionIsNotSaved);
            }

            var uniqueName   = EnvDTEProjectInfoUtility.GetUniqueName(project);
            var nugetProject = await SolutionManager.GetNuGetProjectAsync(uniqueName);

            // If we failed to generate a cache entry in the solution manager something went wrong.
            if (nugetProject == null)
            {
                throw new InvalidOperationException(
                          string.Format(Resources.ProjectHasAnInvalidNuGetConfiguration, project.Name));
            }

            // load packages.config. This makes sure that an exception will get thrown if there
            // are problems with packages.config, such as duplicate packages. When an exception
            // is thrown, an error dialog will pop up and this doc window will not be created.
            var installedPackages = await nugetProject.GetInstalledPackagesAsync(CancellationToken.None);

            var uiController = UIFactory.Create(nugetProject);

            var model = new PackageManagerModel(
                uiController,
                isSolution: false,
                editorFactoryGuid: GuidList.guidNuGetEditorType);

            var vsWindowSearchHostfactory = await GetServiceAsync(typeof(SVsWindowSearchHostFactory)) as IVsWindowSearchHostFactory;

            var vsShell = await GetServiceAsync(typeof(SVsShell)) as IVsShell4;

            var control        = new PackageManagerControl(model, Settings.Value, vsWindowSearchHostfactory, vsShell, OutputConsoleLogger);
            var windowPane     = new PackageManagerWindowPane(control);
            var guidEditorType = GuidList.guidNuGetEditorType;
            var guidCommandUI  = Guid.Empty;
            var caption        = string.Format(
                CultureInfo.CurrentCulture,
                Resx.Label_NuGetWindowCaption,
                project.Name);

            IVsWindowFrame windowFrame;
            var            uiShell = await GetServiceAsync(typeof(SVsUIShell)) as IVsUIShell;

            var ppunkDocView = IntPtr.Zero;
            var ppunkDocData = IntPtr.Zero;
            var hr           = 0;

            try
            {
                ppunkDocView = Marshal.GetIUnknownForObject(windowPane);
                ppunkDocData = Marshal.GetIUnknownForObject(model);
                hr           = uiShell.CreateDocumentWindow(
                    windowFlags,
                    documentName,
                    (IVsUIHierarchy)hier,
                    itemId,
                    ppunkDocView,
                    ppunkDocData,
                    ref guidEditorType,
                    null,
                    ref guidCommandUI,
                    null,
                    caption,
                    string.Empty,
                    null,
                    out windowFrame);
            }
            finally
            {
                if (ppunkDocView != IntPtr.Zero)
                {
                    Marshal.Release(ppunkDocData);
                }

                if (ppunkDocData != IntPtr.Zero)
                {
                    Marshal.Release(ppunkDocView);
                }
            }

            ErrorHandler.ThrowOnFailure(hr);
            return(windowFrame);
        }
Ejemplo n.º 25
0
 void Awake()
 {
     solutionManager = GameObject.FindObjectOfType <SolutionManager>();
     centralCell     = GameObject.FindObjectOfType <CentralCellSolution>();
 }
Ejemplo n.º 26
0
        /// <summary>
        /// 获取评测列表的Json信息
        /// </summary>
        /// <param name="lanaugeSupport">评测机支持语言</param>
        /// <param name="count">评测机请求个数</param>
        /// <returns>评测列表Json信息</returns>
        public static Boolean TryGetPendingListJson(String lanaugeSupport, String count, out String result, out String error)
        {
            result = String.Empty;

            try
            {
                error = JudgeStatusManager.GetJudgeServerLoginStatus();

                if (!String.IsNullOrEmpty(error))
                {
                    return(false);
                }

                StringBuilder         ret          = new StringBuilder();
                Int32                 requestCount = Math.Max(1, count.ToInt32(1));
                List <SolutionEntity> pendingList  = SolutionManager.JudgeGetPendingSolution(requestCount, GetJudgeSupportLanguages(lanaugeSupport));

                Dictionary <Int32, ProblemEntity> problemCache        = new Dictionary <Int32, ProblemEntity>();
                Dictionary <Int32, String>        problemVersionCache = new Dictionary <Int32, String>();

                ProblemEntity  problem            = null;
                String         problemDataVersion = String.Empty;
                SolutionEntity solution           = null;
                Int32          listCount          = (pendingList == null ? 0 : pendingList.Count);

                ret.Append("[");

                for (Int32 i = 0; i < listCount; i++)
                {
                    if (i > 0)
                    {
                        ret.Append(",");
                    }

                    solution = pendingList[i];

                    if (!problemCache.TryGetValue(solution.ProblemID, out problem))
                    {
                        problem = ProblemManager.GetJudgeProblem(solution.ProblemID);
                        problemCache[solution.ProblemID] = problem;
                    }

                    if (!problemVersionCache.TryGetValue(solution.ProblemID, out problemDataVersion))
                    {
                        problemDataVersion = ProblemDataManager.GetProblemDataVersion(solution.ProblemID);
                        problemVersionCache[solution.ProblemID] = problemDataVersion;
                    }

                    if (problem != null)
                    {
                        Double scale       = solution.LanguageType.Scale;
                        Int32  timeLimit   = (Int32)(problem.TimeLimit * scale);
                        Int32  memoryLimit = (Int32)(problem.MemoryLimit * scale);

                        ret.Append("{");
                        ret.Append("\"sid\":\"").Append(solution.SolutionID.ToString()).Append("\",");
                        ret.Append("\"pid\":\"").Append(solution.ProblemID.ToString()).Append("\",");
                        ret.Append("\"username\":\"").Append(solution.UserName).Append("\",");
                        ret.Append("\"dataversion\":\"").Append(problemDataVersion).Append("\",");
                        ret.Append("\"timelimit\":\"").Append(timeLimit.ToString()).Append("\",");
                        ret.Append("\"memorylimit\":\"").Append(memoryLimit.ToString()).Append("\",");
                        ret.Append("\"language\":\"").Append(solution.LanguageType.Type).Append("[]\",");
                        ret.Append("\"sourcecode\":\"").Append(JsonEncoder.JsonEncode(solution.SourceCode)).Append("\"");
                        ret.Append("}");
                    }
                }

                ret.Append("]");

                result = ret.ToString();
                return(true);
            }
            catch (System.Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }
Ejemplo n.º 27
0
        private async System.Threading.Tasks.Task RestorePackagesOrCheckForMissingPackages(vsBuildScope scope)
        {
            _msBuildOutputVerbosity = GetMSBuildOutputVerbositySetting(_dte);
            var waitDialogFactory = ServiceLocator.GetGlobalService <SVsThreadedWaitDialogFactory, IVsThreadedWaitDialogFactory>();

            waitDialogFactory.CreateInstance(out _waitDialog);
            var token = CancellationTokenSource.Token;

            try
            {
                if (IsConsentGranted())
                {
                    if (scope == vsBuildScope.vsBuildScopeSolution || scope == vsBuildScope.vsBuildScopeBatch || scope == vsBuildScope.vsBuildScopeProject)
                    {
                        TotalCount = (await PackageRestoreManager.GetMissingPackagesInSolution(token)).ToList().Count;
                        if (TotalCount > 0)
                        {
                            if (_outputOptOutMessage)
                            {
                                _waitDialog.StartWaitDialog(
                                    Resources.DialogTitle,
                                    Resources.RestoringPackages,
                                    String.Empty,
                                    varStatusBmpAnim: null,
                                    szStatusBarText: null,
                                    iDelayToShowDialog: 0,
                                    fIsCancelable: true,
                                    fShowMarqueeProgress: true);
                                WriteLine(VerbosityLevel.Quiet, Resources.PackageRestoreOptOutMessage);
                                _outputOptOutMessage = false;
                            }

                            System.Threading.Tasks.Task waitDialogCanceledCheckTask = System.Threading.Tasks.Task.Run(() =>
                            {
                                // Just create an extra task that can keep checking if the wait dialog was cancelled
                                // If so, cancel the CancellationTokenSource
                                bool canceled = false;
                                try
                                {
                                    while (!canceled && CancellationTokenSource != null && !CancellationTokenSource.IsCancellationRequested && _waitDialog != null)
                                    {
                                        _waitDialog.HasCanceled(out canceled);
                                        // Wait on the cancellation handle for 100ms to avoid checking on the wait dialog too frequently
                                        CancellationTokenSource.Token.WaitHandle.WaitOne(100);
                                    }

                                    CancellationTokenSource.Cancel();
                                }
                                catch (Exception)
                                {
                                    // Catch all and don't throw
                                    // There is a slight possibility that the _waitDialog was set to null by another thread right after the check for null
                                    // So, it could be null or disposed. Just ignore all errors
                                }
                            });

                            System.Threading.Tasks.Task whenAllTaskForRestorePackageTasks =
                                System.Threading.Tasks.Task.WhenAll(SolutionManager.GetNuGetProjects().Select(nuGetProject => RestorePackagesInProject(nuGetProject, token)));

                            await System.Threading.Tasks.Task.WhenAny(whenAllTaskForRestorePackageTasks, waitDialogCanceledCheckTask);

                            // Once all the tasks are completed, just cancel the CancellationTokenSource
                            // This will prevent the wait dialog from getting updated
                            CancellationTokenSource.Cancel();
                        }
                    }
                    else
                    {
                        throw new NotImplementedException();
                    }
                }
                else
                {
                    _waitDialog.StartWaitDialog(
                        Resources.DialogTitle,
                        Resources.RestoringPackages,
                        String.Empty,
                        varStatusBmpAnim: null,
                        szStatusBarText: null,
                        iDelayToShowDialog: 0,
                        fIsCancelable: true,
                        fShowMarqueeProgress: true);
                    CheckForMissingPackages((await PackageRestoreManager.GetMissingPackagesInSolution(token)).ToList());
                }
            }
            finally
            {
                int canceled;
                _waitDialog.EndWaitDialog(out canceled);
                _waitDialog = null;
            }

            await PackageRestoreManager.RaisePackagesMissingEventForSolution(CancellationToken.None);
        }
Ejemplo n.º 28
0
 static void Main(string[] args)
 {
     SolutionManager.GenericBoxOfString();
 }
Ejemplo n.º 29
0
        private async Task <IVsWindowFrame> CreateDocWindowForSolutionAsync()
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            IVsWindowFrame windowFrame = null;
            var            solution    = await this.GetServiceAsync <IVsSolution>();

            var uiShell = await this.GetServiceAsync <SVsUIShell, IVsUIShell>();

            var windowFlags =
                (uint)_VSRDTFLAGS.RDT_DontAddToMRU |
                (uint)_VSRDTFLAGS.RDT_DontSaveAs;

            if (await SolutionManager.SolutionHasDeferredProjectsAsync() && !SolutionManager.IsInitialized)
            {
                // when VSSolutionManager is not yet initialized, then do a quick pre-condition checks without initializing it fully
                // which might take some time so we'll initialize it after showing the manager ui window.
                var preCheckResult = await SolutionManager.CheckSolutionUIPreConditionsAsync();

                // key represent if solution is available or not.
                if (!preCheckResult.Key)
                {
                    throw new InvalidOperationException(Resources.SolutionIsNotSaved);
                }

                // value represent if there is any project in the solution which NuGet supports.
                if (!preCheckResult.Value)
                {
                    // NOTE: The menu 'Manage NuGet Packages For Solution' will be disabled in this case.
                    // But, it is possible, that, before NuGetPackage is loaded in VS, the menu is enabled and used.
                    // For once, this message will be shown. Once the package is loaded, the menu will get disabled as appropriate
                    MessageHelper.ShowWarningMessage(Resources.NoSupportedProjectsInSolution, Resources.ErrorDialogBoxTitle);
                    return(null);
                }
            }
            else
            {
                // when VSSolutionManager is already initialized, then use the existing APIs to check pre-conditions.
                if (!await SolutionManager.IsSolutionAvailableAsync())
                {
                    throw new InvalidOperationException(Resources.SolutionIsNotSaved);
                }

                var projects = await SolutionManager.GetNuGetProjectsAsync();

                if (!projects.Any())
                {
                    MessageHelper.ShowWarningMessage(Resources.NoSupportedProjectsInSolution, Resources.ErrorDialogBoxTitle);
                    return(null);
                }
            }

            // pass empty array of NuGetProject
            var uiController = UIFactory.Create(new NuGetProject[0]);

            var solutionName = (string)_dte.Solution.Properties.Item("Name").Value;

            var model = new PackageManagerModel(
                uiController,
                isSolution: true,
                editorFactoryGuid: GuidList.guidNuGetEditorType)
            {
                SolutionName = solutionName
            };

            var vsWindowSearchHostfactory = await GetServiceAsync(typeof(SVsWindowSearchHostFactory)) as IVsWindowSearchHostFactory;

            var vsShell = await GetServiceAsync(typeof(SVsShell)) as IVsShell4;

            var control        = new PackageManagerControl(model, Settings.Value, vsWindowSearchHostfactory, vsShell, OutputConsoleLogger);
            var windowPane     = new PackageManagerWindowPane(control);
            var guidEditorType = GuidList.guidNuGetEditorType;
            var guidCommandUI  = Guid.Empty;
            var caption        = Resx.Label_SolutionNuGetWindowCaption;
            var documentName   = _dte.Solution.FullName;

            var ppunkDocView = IntPtr.Zero;
            var ppunkDocData = IntPtr.Zero;
            var hr           = 0;

            try
            {
                ppunkDocView = Marshal.GetIUnknownForObject(windowPane);
                ppunkDocData = Marshal.GetIUnknownForObject(model);
                hr           = uiShell.CreateDocumentWindow(
                    windowFlags,
                    documentName,
                    (IVsUIHierarchy)solution,
                    (uint)VSConstants.VSITEMID.Root,
                    ppunkDocView,
                    ppunkDocData,
                    ref guidEditorType,
                    null,
                    ref guidCommandUI,
                    null,
                    caption,
                    string.Empty,
                    null,
                    out windowFrame);
            }
            finally
            {
                if (ppunkDocView != IntPtr.Zero)
                {
                    Marshal.Release(ppunkDocData);
                }

                if (ppunkDocData != IntPtr.Zero)
                {
                    Marshal.Release(ppunkDocView);
                }
            }

            ErrorHandler.ThrowOnFailure(hr);
            return(windowFrame);
        }
        private void BeforeQueryStatusForPackageRestore(object sender, EventArgs args)
        {
            ThreadHelper.JoinableTaskFactory.Run(async delegate
            {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                OleMenuCommand command = (OleMenuCommand)sender;

                // Enable the 'Restore NuGet Packages' dialog menu
                // a) if the console is NOT busy executing a command, AND
                // b) if the solution exists and not debugging and not building AND
                // c) if there are no NuGetProjects. This means that there no loaded, supported projects
                command.Enabled = !ConsoleStatus.IsBusy && IsSolutionExistsAndNotDebuggingAndNotBuilding() && SolutionManager.GetNuGetProjects().Any();
            });
        }
Ejemplo n.º 31
0
 public SolutionChangedEventArgs(SolutionManager newSolution, SolutionManager oldSolution)
 {
     this.NewSolution = newSolution;
     this.OldSolution = oldSolution;
 }