public static ConfigAndPlatformOfCondition ( string condition ) : string>.Tuple |
||
condition | string | |
return | string>.Tuple |
public static Tuple<string, string> ConfigAndPlatformOfCondition(string condition)
{
condition = condition.Trim();
var rxConfigurationOnly = new Regex(@"\s*'\$\s*\(\s*Configuration\s*\)'\s*==\s*'(\w+)'\s*");
var match1 = rxConfigurationOnly.Match(condition);
if (match1.Success)
return Tuple.Create(match1.Groups[1].Value, "");
var rxConfigurationAntPlatform = new Regex(@"\s*'\$\s*\(\s*Configuration\s*\)\|\$\s*\(\s*Platform\s*\)'\s*==\s*'(\w+)\|(\w+)'\s*");
var match2 = rxConfigurationAntPlatform.Match(condition);
if (match2.Success)
return Tuple.Create(match2.Groups[1].Value, match2.Groups[2].Value);
return Tuple.Create("", "");
}
/// <summary> /// Deletes a specified platform name. /// </summary> /// <param name="platName">The platform name to delet.</param> /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code.</returns> public virtual int DeleteCfgsOfPlatformName(string platName) { if (!this.ProjectMgr.QueryEditProjectFile(false)) { throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED); } var platform = ProjectConfig.ToMSBuildPlatform(platName); if (platform != null) { ProjectMgr.BuildProject.ReevaluateIfNecessary(); var inputElements = new List <ProjectPropertyGroupElement>(this.project.BuildProject.Xml.PropertyGroups); var elementsToRemove = new List <ProjectPropertyGroupElement>(); foreach (ProjectPropertyGroupElement element in inputElements) { var cfgNameAndPlatform = ProjectConfig.ConfigAndPlatformOfCondition(element.Condition); if (ProjectConfig.EqPlatform(cfgNameAndPlatform.Item2, platform)) { elementsToRemove.Add(element); this.configurationsList.Remove(ProjectConfig.MakeConfigKey(cfgNameAndPlatform.Item1, cfgNameAndPlatform.Item2)); } } foreach (ProjectPropertyGroupElement element2 in elementsToRemove) { element2.Parent.RemoveChild(element2); } NotifyOnPlatformNameDeleted(platform); } return(VSConstants.S_OK); }