コード例 #1
0
ファイル: Utils.cs プロジェクト: binhntam/CongCuDungCu
        private static int CalculateRank(List <string[]> requests, DemoPageModel demo)
        {
            var resultRank  = 0;
            var keywordRank = 0;

            foreach (var request in requests)
            {
                var requestRank = -1;
                if (CalculateRank(request, demo.KeywordsRankList, out keywordRank))
                {
                    requestRank += keywordRank;
                }
                if (CalculateRank(request, demo.Group.KeywordsRankList, out keywordRank))
                {
                    requestRank += keywordRank;
                }
                if (CalculateRank(request, demo.Product.KeywordsRankList, out keywordRank))
                {
                    requestRank += keywordRank;
                }
                if (requestRank == -1 && WordsExclusions.Any(re => re.Equals(request[0], StringComparison.InvariantCultureIgnoreCase)))
                {
                    requestRank = 0;
                }
                if (requestRank > -1)
                {
                    resultRank += requestRank;
                }
                else
                {
                    return(-1);
                }
            }
            return(resultRank);
        }
コード例 #2
0
ファイル: Utils.cs プロジェクト: binhntam/CongCuDungCu
        private static IEnumerable <SourceCodePage> CreateSourceCodePages(DemoPageModel demo)
        {
            var result = new List <SourceCodePage>();

            if (IsMvc)
            {
                foreach (string fileName in demo.SourceFiles)
                {
                    if (fileName.StartsWith("~/Models/"))
                    {
                        AddSourceCodePage(result, string.Format("Model ({0})", Path.GetFileNameWithoutExtension(fileName)), fileName, false);
                    }
                }
                var controllerUrl = string.Format("~/Controllers/{0}/{0}Controller.{1}.cs", demo.Group.Key, demo.Key);
                AddSourceCodePage(result, "Controller", controllerUrl, true, false);
                var commonControllerUrl = string.Format("~/Controllers/{0}Controller.cs", demo.Group.Key);
                AddSourceCodePage(result, "Controller (common)", commonControllerUrl, false);
                var viewUrl = string.Format("~/Views/{0}/{1}.cshtml", demo.Group.Key, demo.Key);
                AddSourceCodePage(result, "View", viewUrl, true, false);
                foreach (string fileName in demo.SourceFiles)
                {
                    if (fileName.StartsWith("~/Views/"))
                    {
                        AddSourceCodePage(result, string.Format("View ({0})", Path.GetFileNameWithoutExtension(fileName)), fileName, true);
                    }
                    else
                    {
                        if (fileName.StartsWith("~/Code/"))
                        {
                            AddSourceCodePage(result, string.Format("{0}", Path.GetFileName(fileName)), fileName, true);
                        }
                        else
                        {
                            if (!fileName.StartsWith("~/Models/"))
                            {
                                AddSourceCodePage(result, Path.GetFileName(fileName), fileName, false);
                            }
                        }
                    }
                }
            }
            else
            {
                var baseUrl = GenerateDemoUrl(demo);
                AddSourceCodePage(result, "ASPX", baseUrl, true);
                AddSourceCodePage(result, "C#", baseUrl + ".cs", CodeLanguage == "C#");
                AddSourceCodePage(result, "VB", baseUrl + ".vb", CodeLanguage == "VB");
                foreach (string fileName in demo.SourceFiles)
                {
                    AddSourceCodePage(result, Path.GetFileName(fileName), fileName, false);
                }
            }
            return(result);
        }
コード例 #3
0
ファイル: Utils.cs プロジェクト: binhntam/CongCuDungCu
 public static IEnumerable <SourceCodePage> GetSourceCodePages(DemoPageModel demo)
 {
     lock (sourceCodeCacheLock)
     {
         if (!sourceCodeCache.ContainsKey(demo))
         {
             sourceCodeCache[demo] = CreateSourceCodePages(demo);
         }
         return(sourceCodeCache[demo]);
     }
 }
コード例 #4
0
ファイル: Utils.cs プロジェクト: binhntam/CongCuDungCu
        private static DemoPageModel CreateBogusDemoModel()
        {
            var group = new DemoGroupModel();

            group.Title = "ASP.NET";

            var result = new DemoPageModel();

            result.Group          = group;
            result.HideSourceCode = true;
            result.Title          = "Delivered!";

            return(result);
        }