/// <summary> /// Resolve the <see cref="OrderedItemList{T}"/> from a <see cref="IEnumerable{OrderedItem}"/> that shall represent an ordered list of <see cref="Guid"/> /// </summary> /// <typeparam name="T">A type of <see cref="Thing"/></typeparam> /// <param name="list">The ordered list to resolve</param> /// <param name="orderedItemList">The source <see cref="IEnumerable{OrderedItem}"/></param> /// <param name="iterationId">The potential <see cref="Iteration"/>'id at the top of the containment tree</param> /// <param name="cache">The cache that stores the <see cref="Thing"/>s</param> internal static void ResolveList <T>(this OrderedItemList <T> list, IEnumerable <OrderedItem> orderedItemList, Guid?iterationId, ConcurrentDictionary <CacheKey, Lazy <CommonData.Thing> > cache) where T : Thing { list.Clear(); var orderedList = new List <OrderedItem>(); foreach (var item in orderedItemList) { if (!Guid.TryParse(item.V.ToString(), out var guid)) { logger.Error("The ordered item does not represent a Thing."); continue; } if (cache.TryGet(guid, iterationId, out T thing)) { var ordereditem = new OrderedItem { K = item.K, V = thing }; orderedList.Add(ordereditem); if (list.IsComposite) { thing.ChangeKind = ChangeKind.None; } } } list.AddOrderedItems(orderedList); }
/// <summary> /// Clear and add to the <see cref="OrderedItemList{T}"/> from a <see cref="IEnumerable{OrderedItem}"/> /// </summary> /// <typeparam name="T">The generic type of the <see cref="OrderedItemList{T}"/>. This should be a primitive type that matches the value of the <see cref="DTO.Thing"/>'s <see cref="IEnumerable{OrderedItem}"/></typeparam> /// <param name="list">The <see cref="OrderedItemList{T}"/> to resolve</param> /// <param name="orderedItemList">The source <see cref="IEnumerable{OrderedItem}"/></param> internal static void ClearAndAddRange <T>(this OrderedItemList <T> list, IEnumerable <OrderedItem> orderedItemList) { list.Clear(); list.AddOrderedItems(orderedItemList); }