Exemple #1
0
        private static bool getStartupProjectAndConfigR(EnvDTE.Project project, String startup, out VCProjectW o_proj, out VCConfigurationW o_conf)
        {
            o_proj = null;
            o_conf = null;
            if (project.Kind == EnvDTE.Constants.vsProjectKindSolutionItems)
            {
                foreach (ProjectItem item in project.ProjectItems)
                {
                    EnvDTE.Project child = item.SubProject;
                    if (child != null)
                    {
                        if (getStartupProjectAndConfigR(child, startup, out o_proj, out o_conf))
                        {
                            return(true);
                        }
                    }
                }
            }
            else
            {
                if (!matchTypeName(project.Object, "VCProjectShim"))
                {
                    return(false);
                }
                VCProjectW vcproj = new VCProjectW(project.Object);
                o_proj = vcproj;

                if (project.UniqueName == startup)
                {
                    String         configname = project.ConfigurationManager.ActiveConfiguration.ConfigurationName + "|" + project.ConfigurationManager.ActiveConfiguration.PlatformName;
                    IVCCollectionW cfgs       = vcproj.Configurations;
                    int            num        = cfgs.Count;
                    for (int i = 1; i <= num; ++i)
                    {
                        VCConfigurationW c = cfgs.Item(i);
                        if (c.Name == configname)
                        {
                            o_conf = c;
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Exemple #2
0
        public static bool getActiveProjectAndConfig(DTE app, out VCProjectW out_proj, out VCConfigurationW out_conf)
        {
            out_proj = null;
            out_conf = null;

            Document doc = app.ActiveDocument;

            if (doc == null)
            {
                return(false);
            }

            ProjectItem item = doc.ProjectItem;

            if (!matchTypeName(item.Object, "VCProjectFileShim"))
            {
                return(false);
            }

            EnvDTE.Project proj       = item.ContainingProject;
            VCFileW        vcfile     = new VCFileW(item.Object);
            VCProjectW     vcproj     = vcfile.project;
            String         configname = proj.ConfigurationManager.ActiveConfiguration.ConfigurationName + "|" + proj.ConfigurationManager.ActiveConfiguration.PlatformName;
            IVCCollectionW cfgs       = vcproj.Configurations;
            int            num        = cfgs.Count;

            for (int i = 1; i <= num; ++i)
            {
                VCConfigurationW c    = cfgs.Item(i);
                String           name = (String)getProperty(c, "Name");
                if (name == configname)
                {
                    out_proj = vcproj;
                    out_conf = c;
                    return(true);
                }
            }

            return(false);
        }