Exemple #1
0
        public void Init()
        {
            LinkMap.Add("post", "wojilu.Test.Web.Mvc.TestPostController");            // 映射controller
            LinkMap.Add("category", "wojilu.Test.Web.Mvc.TestPostController.List");   // 映射action
            LinkMap.Add("product", "wojilu.Test.Web.Mvc.TestPostController.Product"); // 映射action_id
            LinkMap.Add("cm", "wojilu.Test.Web.Mvc.Admin.TestCommentController");
            LinkMap.Add("u", "wojilu.Test.Web.Mvc.Admin.Users.TestUserController");
            LinkMap.Add("addr", "wojilu.Test.Web.Mvc.Admin.Users.TestUserController.Address");

            LinkMap.Add("blog", "wojilu.Test.Web.Mvc.Blog.BlogController");
        }
Exemple #2
0
        public void AddProjection(string fieldName, IEvaluable field)
        {
            if (field is BinaryExpression)
            {
                fieldName = ((BinaryExpression)field).Alias;
            }

            if (!_projections.ContainsKey(fieldName))
            {
                _projections.Add(fieldName, field);
            }
            else
            {
                throw new QuerySystemException(ErrorCodes.Query.QUERYCRITERIA_FIELD_ALREADY_EXISTS, new[] { fieldName });
            }
        }
Exemple #3
0
 public void AddField(Field field)
 {
     _individualFields.Add(field.ToString(), field);
 }
Exemple #4
0
        private void FindRelevantCodeLinks(Repository docRepo, Repository codeRepo)
        {
            var dir      = Path.Combine(DocPath, ArticlesRoot1);
            var files    = Directory.GetFiles(dir, "*.md", SearchOption.AllDirectories);
            var pattern1 = "[!code-";
            var pattern2 = $"](~/../{CodeInfo.PathToRoot}/";

            foreach (var file in files)
            {
                var relDocPath = file.Substring(DocPath.Length + 1);
                var docFile    = new CodeLinkMap.FileData
                {
                    BranchName  = docRepo.Head.FriendlyName,
                    RelFilePath = relDocPath.Trim().Replace('\\', '/'),
                };

                var lines = File.ReadAllLines(file).ToList();
                for (var lineNum = 0; lineNum < lines.Count; lineNum++)
                {
                    // The array of lines is 0-based, but "line numbers" are 1-based.
                    var line = lines[lineNum];
                    if (line.StartsWith(pattern1, StringComparison.InvariantCultureIgnoreCase))
                    {
                        var pos = line.IndexOf(pattern2, StringComparison.InvariantCultureIgnoreCase);
                        if (pos < 0)
                        {
                            Status.WriteLine(Severity.Information,
                                             $"Ignoring link in {relDocPath,-64} line {lineNum + 1,3}:  {line}");
                            continue;
                        }

                        var start = pos + pattern2.Length;
                        var end   = line.IndexOf(")]", start);
                        if (end < 0)
                        {
                            Status.WriteLine(Severity.Warning,
                                             $"Poorly formed code link in {relDocPath} at line {lineNum + 1}.");
                            continue;
                        }

                        pos = line.IndexOf('?', start);
                        string relCodePath, queryParameters;
                        if (pos < 0)
                        {
                            relCodePath     = line.Substring(start, end - start);
                            queryParameters = null;
                        }
                        else
                        {
                            relCodePath = line.Substring(start, pos - start);
                            pos++;
                            queryParameters = line.Substring(pos, end - pos);
                        }

                        var codeFile = new CodeLinkMap.FileData
                        {
                            BranchName  = codeRepo.Head.FriendlyName,
                            RelFilePath = relCodePath.Trim(),
                        };

                        LinkMap.Add(docFile, codeFile, lineNum + 1, queryParameters);
                    }
                }
            }
        }