public static string GenerateDemoSectionUrl(BootstrapDemoSectionModel section) { if (section.Demo != null) { return(string.Format("{0}#{1}", GenerateDemoPageUrl(section.Demo), section.Key)); } return(string.Empty); }
public static string GetSourceFileCode(string fileName) { fileName = fileName.ToLowerInvariant(); if (!sourceFilesCode.ContainsKey(fileName)) { string code = BootstrapDemoSectionModel.GetCodeFromFile(fileName); sourceFilesCode.AddOrUpdate(fileName, BootstrapDemoSectionCodeParser.GetFormattedCustomCode(code), (exCode, nCode) => nCode); } return(sourceFilesCode[fileName]); }
static IEnumerable <BootstrapSearchResult> GetRes(List <string[]> requests, BootstrapDemoPageModelBase demo, BootstrapDemoSectionModel section, string text) { var results = new List <BootstrapSearchResult>(); var rank = CalculateRank(requests, demo, section); if (rank > -1) { var sr = new BootstrapSearchResult(demo, section, rank); sr.Text = text; results.Add(sr); } return(results); }
public BootstrapSearchResult(BootstrapDemoPageModelBase demo, BootstrapDemoSectionModel section, int rank) { Demo = demo; Rank = rank; Section = section; }
static int CalculateRank(List <string[]> requests, BootstrapDemoModelBase demo, BootstrapDemoSectionModel section) { int resultRank = 0; int keywordRank = 0; foreach (var request in requests) { int requestRank = -1; if (section != null && demo is BootstrapDemoPageModel && ((BootstrapDemoPageModel)demo).Sections.Count > 1 && SearchAgregator.CalculateRank(request, section.KeywordsRankList, out keywordRank)) { requestRank += keywordRank; } if (SearchAgregator.CalculateRank(request, demo.KeywordsRankList, out keywordRank)) { requestRank += keywordRank; } if (demo is BootstrapDemoGroupPageModel && SearchAgregator.CalculateRank(request, ((BootstrapDemoGroupPageModel)demo).KeywordsRankList, out keywordRank)) { requestRank += keywordRank; } if (requestRank == -1 && Search.WordsExclusions.Any(re => re.Equals(request[0], SearchAgregator.DefaultStringComparison))) { requestRank = 0; } if (requestRank > -1) { resultRank += requestRank; } else { return(-1); } } return(resultRank); }