Esempio n. 1
0
        // Very awkward procedure that accesses global state in the name of only doing one iteration
        internal static void AddTagsToFMAndGlobalList(
            string tagsToAdd,
            FMCategoriesCollection existingFMTags,
            bool addToGlobalList = true)
        {
            if (tagsToAdd.IsWhiteSpace())
            {
                return;
            }

            string[] tagsArray = tagsToAdd.Split(CA_CommaSemicolon, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < tagsArray.Length; i++)
            {
                if (!TryGetCatAndTag(tagsArray[i], out string cat, out string tag) ||
                    cat.IsEmpty() || tag.IsEmpty())
                {
                    continue;
                }

                #region FM tags

                if (existingFMTags.TryGetValue(cat, out FMTagsCollection tagsList))
                {
                    tagsList.Add(tag);
                }
                else
                {
                    existingFMTags.Add(cat, new FMTagsCollection {
                        tag
                    });
                }

                #endregion

                if (!addToGlobalList)
                {
                    continue;
                }

                #region Global tags

                if (GlobalTags.TryGetValue(cat, out FMTagsCollection globalTagsList))
                {
                    globalTagsList.Add(tag);
                }
                else
                {
                    GlobalTags.Add(cat, new FMTagsCollection {
                        tag
                    });
                }

                #endregion
            }
        }