/// <summary> /// Removes all values of a property from all projects /// (for a given configuration/platform) /// </summary> /// <param name="name"></param> /// <param name="val"></param> public void Move(string name, string val) { Parallel.ForEach(_allProjects, proj => { ProjectProperty p = proj.GetProperty(name); if (p != null && !p.IsEnvironmentProperty && !p.IsGlobalProperty && !p.IsImported && !p.IsReservedProperty) { proj.RemoveProperty(p); } }); if (_allFoundProperties.ContainsKey(name)) { ReferencedProperty refp = _allFoundProperties[name]; refp.RemoveProjects(_allProjects); if (refp.UsedCount == 0) { bool removed = _allFoundProperties.Remove(name); Debug.Assert(removed, "Property was not removed from the list"); } } UpdatePropertySheet(name, val); }
public void Remove(ReferencedValues val) { ReferencedProperty owner = val.Owner; owner.Remove(val); if (owner.UsedCount == 0) { _allFoundProperties.Remove(owner.Name); } // This is a delete, not a move. Do not update the property sheet here. }
public void MoveValueAllConfigs(ReferencedValues val) { ReferencedProperty owner = val.Owner; owner.RemoveAllConfigs(val); if (owner.UsedCount == 0) { _allFoundProperties.Remove(owner.Name); } UpdatePropertySheet(owner.Name, val.EvaluatedValue); }
/// <summary> /// Removes properties from all configurations in all files. /// It actually ignores the global configuration and global platform /// and operates on just the raw XML elements. /// </summary> /// <param name="propNames"></param> public void RemoveXml(List <string> propNames) { foreach (var name in propNames) { foreach (var project in _allProjects) { var deleteThese = new List <ProjectPropertyElement>(); var emptyGroups = new List <ProjectPropertyGroupElement>(); ProjectRootElement root = project.Xml; foreach (var group in root.PropertyGroups) { foreach (ProjectPropertyElement prop in group.Properties) { if (String.Compare(name, prop.Name, StringComparison.InvariantCultureIgnoreCase) == 0) { deleteThese.Add(prop); } } } foreach (var prop in deleteThese) { prop.Parent.RemoveChild(prop); } foreach (var group in root.PropertyGroups) { if (group.Children.Count == 0) { // Parents have no more children. Mark them for deletion. emptyGroups.Add(group); } } foreach (var group in emptyGroups) { group.Parent.RemoveChild(group); } project.Save(); } if (_allFoundProperties.ContainsKey(name)) { ReferencedProperty refp = _allFoundProperties[name]; refp.RemoveProjects(_allProjects); if (refp.UsedCount == 0) { bool removed = _allFoundProperties.Remove(name); Debug.Assert(removed, "Property was not removed from the list"); } } } }
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { bool valid = value is ObservableConcurrentDictionary <String, ReferencedValues>; if (valid) { var dict = (ObservableConcurrentDictionary <String, ReferencedValues>)value; ReferencedValues refVal; foreach (var pair in dict) { refVal = pair.Value; ReferencedProperty prop = refVal.Owner; return(new KeyValuePair <String, ReferencedProperty>(prop.Name, prop)); } } return(null); }
public void PrintFoundProperties() { Utils.WL(ConsoleColor.DarkCyan, String.Format("Global Properties: Configuration => {0}", _globalProperties["Configuration"])); Utils.WL(ConsoleColor.DarkCyan, String.Format("Global Properties: Platform => {0}", _globalProperties["Platform"])); var sorted = from p in _allFoundProperties orderby p.Value.UsedCount descending select p; foreach (var pair in sorted) { ReferencedProperty prop = pair.Value; Utils.WL(ConsoleColor.Cyan, String.Format("{0} : {1}", prop.UsedCount, prop.Name)); var sortedVals = from p in prop.PropertyValues orderby p.Value.Count descending select p; foreach (var vp in sortedVals) { ReferencedValues val = vp.Value; Utils.WL(ConsoleColor.DarkCyan, String.Format("\t{0} : {1}", val.Count, val.EvaluatedValue)); } } }
private void GetPropertiesFor(MSBProject project) { foreach (ProjectProperty prop in project.AllEvaluatedProperties) { if (!prop.IsImported && !prop.IsEnvironmentProperty && !prop.IsReservedProperty) { string key = prop.Name; if (_allFoundProperties.ContainsKey(key)) { _allFoundProperties[key].Add(project); } else { _allFoundProperties[key] = new ReferencedProperty(prop, project) { UsedCount = 1 }; } } } }