// Tries to get a pretty name from property passed in, or null if none found public static string PrettyName(this object val) { string name = null; if (val is P.ValueProperty) { P.ValueProperty val_prop = val as P.ValueProperty; if (val_prop.Name != null) { name = val_prop.Name.ToString(); } } if (string.IsNullOrEmpty(name) && val is P.Property) { P.Property prop = val as P.Property; name = prop.GetPathName(); if (!string.IsNullOrEmpty(name)) { name = name.LastName(); } else if (prop.Parent != null) { name = prop.Parent.GetChilds().FindName(prop); //TODO: Could add further checking by traversing parent properties // and checking Properties- resp. PropertyList-related childs //if (string.IsNullOrEmpty(name)) ... } } return(name); }
internal P.Property _FindMatchByPath(P.Property left, P.Properties right_coll) { string left_pathname = left.GetPathName(); if (!string.IsNullOrEmpty(left_pathname)) { foreach (P.Property right in right_coll) { string right_pathname = right.GetPathName(); if (left_pathname.Equals(right_pathname)) { return(right); } } } return(null); }
internal P.Property _FindMatch(P.Property left, P.Properties right_coll) { if (!string.IsNullOrEmpty(left.GetName())) { return(_FindMatchByName(left, right_coll)); } if (!string.IsNullOrEmpty(left.GetPathName())) { return(_FindMatchByPath(left, right_coll)); } if (right_coll.Count > 0) { return(right_coll.First()); } return(null); }