예제 #1
0
        public void RegisterTag(string TagStr, FAllocationTag Tag)
        {
            string CategoryName = "Uncategorized";
            string ActualTag    = TagStr;

            // Split the tag into its category and remaining parts
            int CategorySeparatorIndex = TagStr.IndexOf(':');

            if (CategorySeparatorIndex != -1)
            {
                CategoryName = TagStr.Substring(0, CategorySeparatorIndex);
                ActualTag    = TagStr.Substring(CategorySeparatorIndex + 1);
            }

            // Add the top-level category
            FNode CurrentNode = RootNode;
            {
                int CategoryNameIndex = FStreamInfo.GlobalInstance.GetNameIndex(CategoryName, true);
                CurrentNode = CurrentNode.EnsureChildNode(CategoryNameIndex);
            }

            // Split the remaining parts it hierarchical parts, add a name entry for each tag, and add to the hierarchy
            var HierarchicalTags           = ActualTag.Split(TagPathSeparators, StringSplitOptions.RemoveEmptyEntries);
            var HierarchicalTagNameIndices = new int[HierarchicalTags.Length];

            for (int HierarchicalTagIndex = 0; HierarchicalTagIndex < HierarchicalTags.Length; ++HierarchicalTagIndex)
            {
                int HierarchicalTagNameIndex = FStreamInfo.GlobalInstance.GetNameIndex(HierarchicalTags[HierarchicalTagIndex], true);

                // Are we dealing with a child node, or a tag?
                if (HierarchicalTagIndex + 1 == HierarchicalTags.Length)
                {
                    CurrentNode.EnsureChildTag(HierarchicalTagNameIndex, Tag);
                }
                else
                {
                    CurrentNode = CurrentNode.EnsureChildNode(HierarchicalTagNameIndex);
                }
            }
        }