コード例 #1
0
        public GlobalSearchTerm CreateSectionSearchTermFromName(string name, GlobalSearchTermType type,
                                                                ContentType contentType, string section, string path, string pathOverride)
        {
            var key = path + "#" + name.ToKebabCase();

            if (!string.IsNullOrWhiteSpace(pathOverride))
            {
                key = path + "#" + pathOverride.ToKebabCase();
            }

            var nameWithOptionalSection = name;

            if (!string.IsNullOrWhiteSpace(section))
            {
                nameWithOptionalSection = $"{section} - {name}";
            }

            var searchTerm = new GlobalSearchTerm
            {
                PartitionKey             = contentType.ToString(),
                RowKey                   = Guid.NewGuid().ToString(),
                GlobalSearchTermTypeEnum = type,
                FullName                 = $"{type.ToString().SplitPascalCase()}: {nameWithOptionalSection}",
                Path       = key,
                SearchText = name,
                IsDeleted  = false
            };

            searchTerm.SearchKey = Regex.Replace(searchTerm.FullName, @"[^a-zA-Z0-9-=_]", "");
            return(searchTerm);
        }
コード例 #2
0
        private void HandleSearchTermForProperty(List <string> chapterLines, int startingIndex, string chapterName,
                                                 string path, GlobalSearchTermType globalSearchTermType, List <int> chapterLineIndexesToExclude)
        {
            if (startingIndex > 0)
            {
                var endIndex = chapterLines.FindIndex(startingIndex + 1, f => Regex.IsMatch(f, @"^#{1,3}\s+"));

                var indexes = chapterLines
                              .FindAllIndexOf(f => f.StartsWith("####"))
                              .Where(i => i > startingIndex && i < (endIndex > 0 ? endIndex : chapterLines.Count - 1))
                              .Except(chapterLineIndexesToExclude);

                foreach (var index in indexes)
                {
                    var line          = chapterLines.ElementAt(index);
                    var repeatIndexes = chapterLines.FindAllIndexOf(f => f == line);
                    var name          = line.RemoveHashtagCharacters().Trim();

                    var instance   = repeatIndexes.IndexOf(index) + 1;
                    var searchTerm = _globalSearchTermRepository.CreateSectionSearchTermFromName(name,
                                                                                                 globalSearchTermType, ContentType.Core, chapterName, $"/rules/sotg/{path}",
                                                                                                 instance > 1 ? $"{name} {instance}" : null);

                    _globalSearchTermRepository.SearchTerms.Add(searchTerm);

                    chapterLineIndexesToExclude.Add(index);
                }
            }
        }
コード例 #3
0
        public GlobalSearchTerm CreateSearchTerm(string name, GlobalSearchTermType type, ContentType contentType,
                                                 string path)
        {
            var searchTerm = new GlobalSearchTerm
            {
                PartitionKey             = contentType.ToString(),
                RowKey                   = Guid.NewGuid().ToString(),
                GlobalSearchTermTypeEnum = type,
                FullName                 = $"{type.ToString().SplitPascalCase()}: {name}",
                Path       = path,
                SearchText = name,
                IsDeleted  = false
            };

            return(searchTerm);
        }