// zhiyuan.peng // new method // if Group not exist, return null public PBXVariantGroup GetExistVariantGroup(string name, string path = null, PBXGroup parent = null) { if (string.IsNullOrEmpty(name)) { return(null); } if (parent == null) { parent = rootGroup; } foreach (KeyValuePair <string, PBXVariantGroup> current in variantGroups) { if (string.IsNullOrEmpty(current.Value.name)) { if (current.Value.path.CompareTo(name) == 0 && parent.HasChild(current.Key)) { return(current.Value); } } else if (current.Value.name.CompareTo(name) == 0 && parent.HasChild(current.Key)) { return(current.Value); } } return(null); }
public PBXGroup GetGroup(string name, string path = null, PBXGroup parent = null) { if (string.IsNullOrEmpty(name)) { return(null); } if (parent == null) { parent = rootGroup; } foreach (KeyValuePair <string, PBXGroup> current in groups) { if (string.IsNullOrEmpty(current.Value.name)) { if (current.Value.path.CompareTo(name) == 0 && parent.HasChild(current.Key)) { return(current.Value); } } else if (current.Value.name.CompareTo(name) == 0 && parent.HasChild(current.Key)) { return(current.Value); } } PBXGroup result = new PBXGroup(name, path); groups.Add(result); parent.AddChild(result); modified = true; return(result); }