Пример #1
0
        public static DataboundAsset FindChildOfType <T>(this DataboundContainterAsset containerAsset) where T : DataboundAsset
        {
            if (containerAsset.Children?.Value == null)
            {
                return(null);
            }

            DataboundAsset correctChild = containerAsset.Children.Value.FirstOrDefault(t => t is T);

            if (correctChild != null)
            {
                return(correctChild);
            }

            foreach (DataboundContainterAsset child in containerAsset.Children.Value.OfType <DataboundContainterAsset>())
            {
                DataboundAsset procChild = child.FindChildOfType <T>();
                if (procChild is T sorted)
                {
                    return(sorted);
                }
            }

            return(null);
        }
Пример #2
0
        public static List <DataboundAsset> FindChildrenOfType <T>(this DataboundContainterAsset containerAsset) where T : DataboundAsset
        {
            List <DataboundAsset> result = new List <DataboundAsset>();

            if (containerAsset.Children?.Value == null)
            {
                return(result);
            }

            result.AddRange(containerAsset.Children.Value.Where(t => t is T));

            foreach (DataboundContainterAsset child in containerAsset.Children.Value.OfType <DataboundContainterAsset>())
            {
                DataboundAsset procChild = child.FindChildOfType <T>();
                if (procChild is T sorted)
                {
                    result.Add(sorted);
                }
            }

            return(result);
        }