Пример #1
0
        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);
        }