Esempio n. 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);
         }
     }
 }
Esempio n. 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);
         }
     }
 }
Esempio n. 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);
         }
     }
 }
Esempio n. 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;
        }
Esempio n. 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;
        }
Esempio n. 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);
        }