/// <summary>
        /// Call this method to assign a default grouping information if a given category
        /// does not have any. A node category's group can either be "Create", "Query" or
        /// "Actions". If none of the group names above is assigned to the category, it
        /// will be assigned a default one that is "Actions".
        ///
        /// For examples:
        ///
        ///     "Core.Evaluate" will be renamed as "Core.Evaluate.Actions"
        ///     "Core.List.Create" will remain as "Core.List.Create"
        ///
        /// </summary>
        internal string ProcessNodeCategory(string category, ref SearchElementGroup group)
        {
            if (string.IsNullOrEmpty(category))
            {
                return(category);
            }

            int index = category.LastIndexOf(Configurations.CategoryDelimiter);

            // If "index" is "-1", then the whole "category" will be used as-is.
            switch (category.Substring(index + 1))
            {
            case Configurations.CategoryGroupAction:
                group = SearchElementGroup.Action;
                break;

            case Configurations.CategoryGroupCreate:
                group = SearchElementGroup.Create;
                break;

            case Configurations.CategoryGroupQuery:
                group = SearchElementGroup.Query;
                break;

            default:
                group = SearchElementGroup.Action;
                return(category);
            }

            return(category.Substring(0, index));
        }
示例#2
0
        public void ProcessNodeCategoryTests()
        {
            SearchElementGroup group    = SearchElementGroup.None;
            string             category = null;

            Assert.AreEqual(null, search.ProcessNodeCategory(category, ref group));
            Assert.AreEqual(SearchElementGroup.None, group);

            group    = SearchElementGroup.None;
            category = "";
            Assert.AreEqual("", search.ProcessNodeCategory(category, ref group));
            Assert.AreEqual(SearchElementGroup.None, group);

            group    = SearchElementGroup.None;
            category = "Builtin Functions";
            Assert.AreEqual("Builtin Functions", search.ProcessNodeCategory(category, ref group));
            Assert.AreEqual(SearchElementGroup.Action, group);

            group    = SearchElementGroup.None;
            category = "Core.Evaluate";
            Assert.AreEqual("Core.Evaluate", search.ProcessNodeCategory(category, ref group));
            Assert.AreEqual(SearchElementGroup.Action, group);

            group    = SearchElementGroup.None;
            category = "Core.List.Create";
            Assert.AreEqual("Core.List", search.ProcessNodeCategory(category, ref group));
            Assert.AreEqual(SearchElementGroup.Create, group);
        }
        public override void Add(NodeSearchElement entry)
        {
            SearchElementGroup group = SearchElementGroup.None;

            entry.FullCategoryName = ProcessNodeCategory(entry.FullCategoryName, ref group);
            entry.Group            = group;

            base.Add(entry);
        }
示例#4
0
        private string AddGroupToCategory(string category, SearchElementGroup group)
        {
            switch (group)
            {
            case SearchElementGroup.Action:
                return(category + Configurations.CategoryDelimiter + Configurations.CategoryGroupAction);

            case SearchElementGroup.Create:
                return(category + Configurations.CategoryDelimiter + Configurations.CategoryGroupCreate);

            case SearchElementGroup.Query:
                return(category + Configurations.CategoryDelimiter + Configurations.CategoryGroupQuery);

            default:
                return(category);
            }
        }
示例#5
0
 private string AddGroupToCategory(string category, SearchElementGroup group)
 {
     switch (group)
     {
         case SearchElementGroup.Action:
             return category + Configurations.CategoryDelimiterString + Configurations.CategoryGroupAction;
         case SearchElementGroup.Create:
             return category + Configurations.CategoryDelimiterString + Configurations.CategoryGroupCreate;
         case SearchElementGroup.Query:
             return category + Configurations.CategoryDelimiterString + Configurations.CategoryGroupQuery;
         default:
             return category;
     }
 }