public CslaObjectInfo FindParent(CslaObjectInfo childInfo) { CslaObjectInfo info = null; if (String.IsNullOrEmpty(childInfo.ParentType)) { foreach (CslaObjectInfo o in childInfo.Parent.CslaObjects) { foreach (ChildProperty p in o.GetAllChildProperties()) { if (p.TypeName == childInfo.ObjectName) { info = o; } } if (info != null) { break; } } } else { info = childInfo.Parent.CslaObjects.Find(childInfo.ParentType); } if (info != null) { if (info.ItemType == childInfo.ObjectName) { return(FindParent(info)); } else if (info.GetAllChildProperties().FindType(childInfo.ObjectName) != null) { return(info); } else if (info.GetCollectionChildProperties().FindType(childInfo.ObjectName) != null) { return(info); } } return(null); }
public static List <string> GetDescendants(this CslaObjectInfo info) { var result = new List <string> { info.ObjectName }; if (info.ObjectType.IsCollectionType()) { result.AddRange(info.Parent.CslaObjects.Find(info.ItemType).GetDescendants()); } foreach (var child in info.GetCollectionChildProperties()) { var childTypeName = child.TypeName; if (childTypeName == string.Empty) { continue; } result.Add(childTypeName); var childInfo = info.Parent.CslaObjects.Find(childTypeName); result.AddRange(info.Parent.CslaObjects.Find(childInfo.ItemType).GetDescendants()); } foreach (var child in info.GetNonCollectionChildProperties()) { var childTypeName = child.TypeName; if (childTypeName == string.Empty) { continue; } result.AddRange(info.Parent.CslaObjects.Find(childTypeName).GetDescendants()); } return(result); }