Microsoft.VisualStudio.Project.ProjectConfig.GetPlatformName C# (CSharp) Method

GetPlatformName() public static method

public static GetPlatformName ( string>.Tuple canonicalConfigName ) : string
canonicalConfigName string>.Tuple
return string
        public static string GetPlatformName(Tuple<string, string> canonicalConfigName)
        {
            return ToPlatformName(canonicalConfigName.Item2);
        }

Usage Example

        /// <summary>
        /// Copies an existing configuration name or creates a new one.
        /// </summary>
        /// <param name="name">The name of the new configuration.</param>
        /// <param name="cloneName">the name of the configuration to copy, or a null reference, indicating that AddCfgsOfCfgName should create a new configuration.</param>
        /// <param name="fPrivate">Flag indicating whether or not the new configuration is private. If fPrivate is set to true, the configuration is private. If set to false, the configuration is public. This flag can be ignored.</param>
        /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code. </returns>
        public virtual int AddCfgsOfCfgName(string name, string cloneName, int fPrivate)
        {
            // We need to QE/QS the project file
            if (!this.ProjectMgr.QueryEditProjectFile(false))
            {
                throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED);
            }

            ProjectMgr.BuildProject.ReevaluateIfNecessary();

            var list       = new List <ProjectPropertyGroupElement>(this.project.BuildProject.Xml.PropertyGroups);
            var dictionary = new Dictionary <string, ProjectPropertyGroupElement>(StringComparer.Ordinal);

            if (cloneName != null)
            {
                foreach (ProjectPropertyGroupElement element in list)
                {
                    if (!string.IsNullOrEmpty(element.Condition))
                    {
                        var cfgNameAndPlatform = ProjectConfig.ConfigAndPlatformOfCondition(element.Condition);
                        //ConfigCanonicalName name2 = ConfigCanonicalName.OfCondition(element.Condition);
                        var platformName = ProjectConfig.GetPlatformName(cfgNameAndPlatform);
                        if ((string.Compare(ProjectConfig.GetConfigName(cfgNameAndPlatform), cloneName, StringComparison.OrdinalIgnoreCase) == 0) && !dictionary.ContainsKey(platformName))
                        {
                            dictionary.Add(platformName, element);
                        }
                    }
                }
            }
            string[] platformsFromProject = this.GetPlatformsFromProject();
            if (platformsFromProject.Length == 0)
            {
                platformsFromProject = new [] { string.Empty }
            }
            ;

            foreach (string latform in platformsFromProject)
            {
                if (dictionary.Count <= 0 || dictionary.ContainsKey(latform))
                {
                    //ConfigCanonicalName name3 = new ConfigCanonicalName(name, latform);
                    ProjectPropertyGroupElement newConfig = null;
                    if (dictionary.ContainsKey(latform))
                    {
                        newConfig = this.project.ClonePropertyGroup(dictionary[latform]);
                        foreach (ProjectPropertyElement element3 in newConfig.Properties)
                        {
                            if (element3.Name.Equals("OutputPath", StringComparison.OrdinalIgnoreCase))
                            {
                                element3.Parent.RemoveChild(element3);
                            }
                        }
                    }
                    else
                    {
                        var msbuildPlatform = ProjectConfig.ToMSBuildPlatform(latform);
                        this.PopulateEmptyConfig(ref newConfig);
                        if (!string.IsNullOrEmpty(msbuildPlatform))
                        {
                            newConfig.AddProperty("PlatformTarget", msbuildPlatform);
                        }
                    }

                    this.AddOutputPath(newConfig, name);
                    newConfig.Condition = ProjectConfig.MakeMSBuildCondition(name, latform);
                }
            }

            NotifyOnCfgNameAdded(name);
            return(VSConstants.S_OK);
        }