Exemple #1
0
 /// <summary>
 /// Selects items keys by the specified index key.
 /// </summary>
 public IEnumerable <int> SelectItemKeys(object indexKey)
 {
     if (ItemGroups.TryGetValue(CastIndexKey(indexKey), out IndexGroup group))
     {
         foreach (int key in group.Keys)
         {
             yield return(key);
         }
     }
 }
Exemple #2
0
 /// <summary>
 /// Selects items by the specified index key.
 /// </summary>
 public IEnumerable SelectItems(object indexKey)
 {
     if (ItemGroups.TryGetValue(CastIndexKey(indexKey), out IndexGroup group))
     {
         foreach (object item in group.Values)
         {
             yield return(item);
         }
     }
 }
Exemple #3
0
 /// <summary>
 /// Selects items by the specified index key.
 /// </summary>
 public IEnumerable SelectItems(int indexKey)
 {
     if (ItemGroups.TryGetValue(indexKey, out SortedDictionary <int, object> group))
     {
         foreach (object item in group.Values)
         {
             yield return(item);
         }
     }
 }
Exemple #4
0
        /// <summary>
        /// Adds the item to the index.
        /// </summary>
        public void AddToIndex(object item, int itemKey)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            TKey indexKey = GetIndexKey(item);

            if (!ItemGroups.TryGetValue(indexKey, out IndexGroup group))
            {
                group = new IndexGroup();
                ItemGroups.Add(indexKey, group);
            }

            group[itemKey] = (TItem)item;
        }
Exemple #5
0
        /// <summary>
        /// Adds the item to the index.
        /// </summary>
        public void AddToIndex(object item, int itemKey)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            int indexKey = GetIndexKey(item);

            if (!ItemGroups.TryGetValue(indexKey, out SortedDictionary <int, object> group))
            {
                group = new SortedDictionary <int, object>();
                ItemGroups.Add(indexKey, group);
            }

            group[itemKey] = item;
        }
Exemple #6
0
        /// <summary>
        /// Removes the item from the index.
        /// </summary>
        public void RemoveFromIndex(object item, int itemKey)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            int indexKey = GetIndexKey(item);

            if (ItemGroups.TryGetValue(indexKey, out SortedDictionary <int, object> group))
            {
                group.Remove(itemKey);
                if (group.Count == 0)
                {
                    ItemGroups.Remove(indexKey);
                }
            }
        }
        private void ParseItemGroup(string line)
        {
            if (IsStartOfState(line) ||
                line.TrimStart().StartsWith(LineMarkers.ItemGroupEnd))
            {
                return;
            }

            var itemGroupType = GetCurrentOrNewItemGroup(line);

            if (!ItemGroups.TryGetValue(itemGroupType, out var lines))
            {
                lines = new List <string>();
                ItemGroups[itemGroupType] = lines;
            }

            lines.Add(line);
        }