/// <summary> /// Get containers of a specific type by addresses /// </summary> /// <typeparam name="T">The type of containers to get</typeparam> /// <param name="targetType">type of contained items these will produce, can be a summary type</param> /// <param name="addresses">list of addresses to fetch (ignored if don't have the container type specified)</param> /// <returns>containers at addresses</returns> public IEnumerable <T> Get <T>(Type targetType, IEnumerable <Address> addresses) where T : class { if (!addresses.Any()) { yield break; } var contentType = addresses.First().Type; var paths = addresses.Where( a => typeof(T).IsAssignableFrom(System.Collator.ContainerType(a.Type)) && a.Type == contentType) .Select(a => a.GetAsContentPath()).ToList(); var pathPiInfo = typeof(T).GetProperties() .Select(pi => new { pi, a = pi.GetCustomAttribute <AddressComponentAttribute>() }) .FirstOrDefault(pii => pii.a != null && pii.a.UsePath); var pathSel = LinqX.GetFieldSelector <T>(pathPiInfo.pi.Name); var repo = Registered(typeof(T)); foreach (var res in repo.Get <T>(targetType, new Type[] { contentType }, iq => iq.WhereIn(pathSel, paths))) { yield return(res); } }