/// <summary> /// Gets an updated and ordered list of graph nodes of a specific length. /// </summary> /// <param name="maxLength">The maximum character length that will be used for the index.</param> /// <param name="acKey">The autocomplete key to potentially be included in this key index.</param> /// <param name="acBlock">The current list of graph nodes already existing and to be reordered based on the acKey property.</param> /// <returns>Returns an ordered list of key value pairs that represents what will display in the search box for the acKey property.</returns> private static GraphNode[] UpdateOrderedJsonBlock(int maxLength, GraphNode acKey, GraphNode[] acBlock) { var keyIndex = acBlock .ToList() .IndexOf(acBlock .Where(aKey => aKey.label.Equals(acKey.label, StringComparison.InvariantCultureIgnoreCase)) .First()); acBlock[keyIndex] = acKey; var acBlockList = acBlock.ToList(); acBlockList = acBlockList .OrderByDescending(acbk => acbk.size) .ToList() .Take(maxLength) .ToList(); acBlock = acBlockList .ToArray(); return acBlock; }
/// <summary> /// Gets an ordered list of graph nodes of a specific length. /// </summary> /// <param name="maxLength">The maximum character length that will be used for the index.</param> /// <param name="acKey">The autocomplete key to potentially be included in this key index.</param> /// <param name="acBlock">The current list of graph nodes already existing and to be reordered based on the acKey property.</param> /// <returns>Returns an ordered list of key value pairs that represents what will display in the search box for the acKey property.</returns> private static GraphNode[] GetOrderedJsonBlock(int maxLength, GraphNode acKey, GraphNode[] acBlock) { List<GraphNode> acBlockList = acBlock.ToList(); acBlockList.Add(acKey); acBlockList = acBlockList .OrderByDescending(acbk => acbk.size) .ToList() .Take(maxLength) .ToList(); acBlock = acBlockList.ToArray(); return acBlock; }