public void ImportTags(IEnumerable <ModuleItem> items) { foreach (var item in items.Where(i => i.GlobalTagId != -1)) { if (!Classes.ContainsKey(item.ClassCode)) { Classes.Add(item.ClassCode, new TagClass(item.ClassCode, item.ClassName)); ItemsByClass.Add(item.ClassCode, new List <ModuleItem>()); } if (!ItemsById.ContainsKey(item.GlobalTagId)) { ItemsById.Add(item.GlobalTagId, item); ItemsByClass[item.ClassCode].Add(item); InstancesById.Add(item.GlobalTagId, new List <ModuleItem> { item }); } if (!InstancesById[item.GlobalTagId].Any(i => i.Module.FileName == item.Module.FileName)) { InstancesById[item.GlobalTagId].Add(item); } } }
/// <summary> /// Adds an item to the in-memory set of items. /// </summary> /// <param name="syncItem"></param> protected void AddItem(SyncItem syncItem) { ID itemId = ParseId(syncItem.ID); if (!ItemsById.ContainsKey(itemId)) { ItemsById.Add(itemId, syncItem); ItemsByParentId.Add(new KeyValuePair <ID, SyncItem>(ParseId(syncItem.ParentID), syncItem)); } }