static public IReadOnlyList <T> EmptyIfNull <T>(this IEnumerable <T> _this) => (_this == null) ? Empty.List <T>() : _this.ToArray();
static IEnumerable <PropertyInfoWithPrefix> _GetAllPublicImplicitInstancePropsRecursive <TOwner, TTypeToExpand>(object owner, Maybe <IPropertyDescriptionChain <TOwner> > chain) where TOwner : class where TTypeToExpand : class { var directProps = Introspector.GetAllPublicImplicitInstanceProps(owner.GetType()); var nodesToExpand = directProps .Where(x => x.PropertyType.Extends <TTypeToExpand>()) .ToList(); foreach (var iDirect in directProps) { var newChain = (chain.Exists) ? (chain.Value.Add(new PropertyDescription(chain.Value.Nodes.Last().ValueType, typeof(TTypeToExpand), iDirect.Name))) : (new PropertyDescriptionChain <TOwner, TTypeToExpand>(new PropertyDescription <TOwner, TTypeToExpand>(propName: iDirect.Name), Empty.List <IPropertyDescription>())) ; if (!iDirect.PropertyType.Extends <TTypeToExpand>()) { yield return(new PropertyInfoWithPrefix(newChain, iDirect, owner)); } else { foreach (var item in _GetAllPublicImplicitInstancePropsRecursive <TOwner, TTypeToExpand>(iDirect, new Maybe <IPropertyDescriptionChain <TOwner> >(newChain))) { yield return(item); } } } }