• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# RepositoryBrowser类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中RepositoryBrowser的典型用法代码示例。如果您正苦于以下问题:C# RepositoryBrowser类的具体用法?C# RepositoryBrowser怎么用?C# RepositoryBrowser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RepositoryBrowser类属于命名空间,在下文中一共展示了RepositoryBrowser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Blob

        public ActionResult Blob(string id, string name, string encodedPath)
        {
            ViewBag.ID = id;
            if (!String.IsNullOrEmpty(id))
            {
                using (var browser = new RepositoryBrowser(Path.Combine(UserConfiguration.Current.Repositories, id)))
                {
                    var path = PathEncoder.Decode(encodedPath);
                    string referenceName;
                    var model = browser.BrowseBlob(name, path, out referenceName);
                    PopulateBranchesData(browser, referenceName);
                    PopulateAddressBarData(name, path);

                    model.Text = FileDisplayHandler.GetText(model.Data);
                    model.IsText = model.Text != null;
                    if (model.IsText)
                        model.TextBrush = FileDisplayHandler.GetBrush(path);
                    else
                        model.IsImage = FileDisplayHandler.IsImage(path);

                    return View(model);
                }
            }
            return View();
        }
开发者ID:sheryever,项目名称:Bonobo-Git-Server,代码行数:25,代码来源:RepositoryController.cs


示例2: LastedCommit

        public ActionResult LastedCommit(int page = 1)
        {
            page = page >= 1 ? page : 1;
            int pageSize = 10;

            var di = new DirectoryInfo(UserConfiguration.Current.Repositories);
            var allRepo = di.GetDirectories("*.*", SearchOption.TopDirectoryOnly);

            var list = new List<ActivityCommitModels>();
            var repoList = this.GetIndexModel();

            foreach (var repoPath in allRepo)
            {
                using (var browser = new RepositoryBrowser(Path.Combine(UserConfiguration.Current.Repositories, repoPath.Name)))
                {
                    var name = PathEncoder.Decode("");
                    string referenceName;
                    int totalCount;
                    var commits = browser.GetCommits(name, 1, 10, out referenceName, out totalCount).ToList();

                    if (commits.Count < 1)
                        continue;

                    var com = commits.OrderByDescending(c => c.Date).FirstOrDefault();

                    var id = com.ID;
                    var committer = com.Author;
                    var committMail = com.AuthorEmail;
                    var committWhen = com.Date;
                    var message = com.Message;

                    if (repoList.Where(r => r.Name == repoPath.Name).FirstOrDefault() == null)
                        continue;

                    var repoGuid = repoList.Where(r => r.Name == repoPath.Name).FirstOrDefault().Id;

                    var ac = new ActivityCommitModels();
                    ac.ProjectName = repoPath.Name;
                    ac.CommitterName = committer;
                    ac.Email = committMail;
                    ac.When = committWhen;
                    ac.Message = message;
                    ac.idSha = id;
                    ac.id = repoGuid;
                    list.Add(ac);

                }
            }

            ViewBag.TotalCount = list.Count;
            var sortList = list.OrderByDescending(c => c.When).ToList();

            if (page >= 1 && pageSize >= 1)
            {
                sortList = sortList.Skip((page - 1) * pageSize).Take(pageSize).ToList();
            }

            return View(sortList);
        }
开发者ID:forgetz,项目名称:Bonobo-Git-Server,代码行数:59,代码来源:ActivityController.cs


示例3: Show

        public ActionResult Show(string repository, string tree, string path)
        {
            var browser = new RepositoryBrowser(Path.Combine(UserConfigurationManager.Repositories, repository));

            var leaf = browser.GetLeaf(tree, path);
            if (leaf != null)
            {
                return new FileStreamResult(new MemoryStream(leaf.RawData), FileDisplayHandler.GetMimeType(Path.GetFileName(path)));
            }
            return null;
        }
开发者ID:rex-dennis,项目名称:Bonobo-Git-Server,代码行数:11,代码来源:ImageController.cs


示例4: Commit

        public ActionResult Commit(string id, string commit)
        {
            ViewBag.ID = id;
            if (!String.IsNullOrEmpty(id))
            {
                using (var browser = new RepositoryBrowser(Path.Combine(UserConfiguration.Current.Repositories, id)))
                {
                    var model = browser.GetCommitDetail(commit);
                    model.Name = id;
                    return View(model);
                }
            }

            return View();
        }
开发者ID:Aimeast,项目名称:Bonobo-Git-Server,代码行数:15,代码来源:RepositoryController.cs


示例5: Commits

        public ActionResult Commits(string id, string name)
        {
            ViewBag.ID = id;
            if (!String.IsNullOrEmpty(id))
            {
                using (var browser = new RepositoryBrowser(Path.Combine(UserConfigurationManager.Repositories, id)))
                {
                    string currentBranchName;
                    var commits = browser.GetCommits(name, out currentBranchName);
                    PopulateBranchesData(browser, currentBranchName);
                    return View(new RepositoryCommitsModel { Commits = commits, Name = id });
                }
            }

            return View();
        }
开发者ID:randome,项目名称:Bonobo-Git-Server,代码行数:16,代码来源:RepositoryController.cs


示例6: Blob

        public ActionResult Blob(string id, string encodedName, string encodedPath)
        {
            ViewBag.ID = id;
            if (!String.IsNullOrEmpty(id))
            {
                using (var browser = new RepositoryBrowser(Path.Combine(UserConfiguration.Current.Repositories, id)))
                {
                    var name = PathEncoder.Decode(encodedName);
                    var path = PathEncoder.Decode(encodedPath);
                    string referenceName;
                    var model = browser.BrowseBlob(name, path, out referenceName);
                    PopulateBranchesData(browser, referenceName);
                    PopulateAddressBarData(path);

                    return View(model);
                }
            }
            return View();
        }
开发者ID:jiangzm,项目名称:Bonobo-Git-Server,代码行数:19,代码来源:RepositoryController.cs


示例7: Download

        public ActionResult Download(string id, string encodedName, string encodedPath)
        {
            if (String.IsNullOrEmpty(id))
                return HttpNotFound();

            var name = PathEncoder.Decode(encodedName);
            var path = PathEncoder.Decode(encodedPath);

            Response.BufferOutput = false;
            Response.Charset = "";
            Response.ContentType = "application/zip";

            string headerValue = ContentDispositionUtil.GetHeaderValue((name ?? id) + ".zip");
            Response.AddHeader("Content-Disposition", headerValue);

            using (var outputZip = new ZipFile())
            {
                outputZip.UseZip64WhenSaving = Zip64Option.Always;
                outputZip.AlternateEncodingUsage = ZipOption.AsNecessary;
                outputZip.AlternateEncoding = Encoding.Unicode;

                using (var browser = new RepositoryBrowser(Path.Combine(UserConfiguration.Current.Repositories, id)))
                {
                    AddTreeToZip(browser, name, path, outputZip);
                }

                outputZip.Save(Response.OutputStream);

                return new EmptyResult();
            }
        }
开发者ID:jiangzm,项目名称:Bonobo-Git-Server,代码行数:31,代码来源:RepositoryController.cs


示例8: Detail

 public ActionResult Detail(string id)
 {
     ViewBag.ID = id;
     if (!String.IsNullOrEmpty(id))
     {
         var model = ConvertRepositoryModel(RepositoryRepository.GetRepository(id));
         if (model != null)
         {
             model.IsCurrentUserAdministrator = RepositoryPermissionService.IsRepositoryAdministrator(User.Identity.Name, id);
         }
         using (var browser = new RepositoryBrowser(Path.Combine(UserConfiguration.Current.Repositories, id)))
         {
             string defaultReferenceName;
             browser.BrowseTree(null, null, out defaultReferenceName);
             RouteData.Values.Add("encodedName", defaultReferenceName);
         }
         return View(model);
     }
     return View();
 }
开发者ID:jiangzm,项目名称:Bonobo-Git-Server,代码行数:20,代码来源:RepositoryController.cs


示例9: Tree

        public ActionResult Tree(string id, string encodedName, string encodedPath)
        {
            bool includeDetails = Request.IsAjaxRequest(); 

            if (String.IsNullOrEmpty(id))
                return View();

            ViewBag.ID = id;
            var name = PathEncoder.Decode(encodedName);
            var path = PathEncoder.Decode(encodedPath);

            using (var browser = new RepositoryBrowser(Path.Combine(UserConfiguration.Current.Repositories, id)))
            {
                string referenceName;
                var files = browser.BrowseTree(name, path, out referenceName, includeDetails);

                var model = new RepositoryTreeModel
                {
                    Name = id,
                    Branch = name,
                    Path = path,
                    Files = files.OrderByDescending(i => i.IsTree).ThenBy(i => i.Name),
                };

                if (includeDetails)
                {
                    return Json(model, JsonRequestBehavior.AllowGet);
                }
                else
                {
                    PopulateBranchesData(browser, referenceName);
                    PopulateAddressBarData(name, path);
                    return View(model);
                }
            }
        }
开发者ID:hammadrauf,项目名称:Bonobo-Git-Server,代码行数:36,代码来源:RepositoryController.cs


示例10: Tree

        public ActionResult Tree(string id, string name, string path)
        {
            ViewBag.ID = id;
            if (!String.IsNullOrEmpty(id))
            {
                using (var browser = new RepositoryBrowser(Path.Combine(UserConfiguration.Current.Repositories, id)))
                {
                    string referenceName;
                    var files = browser.BrowseTree(name, path, out referenceName);
                    PopulateBranchesData(browser, referenceName);
                    PopulateAddressBarData(name, path);

                    var model = new RepositoryTreeModel();
                    model.Name = id;
                    //model.IsTree = true;
                    model.Files = files.OrderByDescending(i => i.IsTree).ThenBy(i => i.Name);
                    return View(model);
                }
            }
            return View();
        }
开发者ID:Aimeast,项目名称:Bonobo-Git-Server,代码行数:21,代码来源:RepositoryController.cs


示例11: Detail

        public ActionResult Detail(Guid id)
        {
            ViewBag.ID = id;

            var model = ConvertRepositoryModel(RepositoryRepository.GetRepository(id), User);
            if (model != null)
            {
                model.IsCurrentUserAdministrator = RepositoryPermissionService.HasPermission(User.Id(), model.Id, RepositoryAccessLevel.Administer);
                SetGitUrls(model);
            }
            using (var browser = new RepositoryBrowser(Path.Combine(UserConfiguration.Current.Repositories, model.Name)))
            {
                string defaultReferenceName;
                browser.BrowseTree(null, null, out defaultReferenceName);
                RouteData.Values.Add("encodedName", defaultReferenceName);
            }

            return View(model);
        }
开发者ID:forgetz,项目名称:Bonobo-Git-Server,代码行数:19,代码来源:RepositoryController.cs


示例12: PopulateBranchesData

 private void PopulateBranchesData(RepositoryBrowser browser, string referenceName)
 {
     ViewData["referenceName"] = referenceName;
     ViewData["branches"] = browser.GetBranches();
     ViewData["tags"] = browser.GetTags();
 }
开发者ID:jiangzm,项目名称:Bonobo-Git-Server,代码行数:6,代码来源:RepositoryController.cs


示例13: Tree

        public ActionResult Tree(string id, string encodedName, string encodedPath)
        {
            bool includeDetails = Request.IsAjaxRequest();

            if (String.IsNullOrEmpty(id))
                return View();

            ViewBag.ID = id;
            var name = PathEncoder.Decode(encodedName);
            var path = PathEncoder.Decode(encodedPath);

            using (var browser = new RepositoryBrowser(Path.Combine(UserConfiguration.Current.Repositories, id)))
            {
                string referenceName;
                var files = browser.BrowseTree(name, path, out referenceName, includeDetails);

                var readme = files.Where(x => x.Path.Equals("readme.md", StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                string readmeTxt = string.Empty;
                if (readme != null)
                {
                    string refereceName;
                    var blob = browser.BrowseBlob(name, readme.Path, out refereceName);
                    readmeTxt = blob.Text;
                }
                var model = new RepositoryTreeModel
                {
                    Name = id,
                    Branch = name,
                    Path = path,
                    Files = files.OrderByDescending(i => i.IsTree).ThenBy(i => i.Name),
                    Readme = readmeTxt
                };

                if (includeDetails)
                {
                    return Json(model, JsonRequestBehavior.AllowGet);
                }
                else
                {
                    PopulateBranchesData(browser, referenceName);
                    PopulateAddressBarData(path);
                    return View(model);
                }
            }
        }
开发者ID:jiangzm,项目名称:Bonobo-Git-Server,代码行数:45,代码来源:RepositoryController.cs


示例14: Commit

 public ActionResult Commit(Guid id, string commit)
 {
     ViewBag.ID = id;
     ViewBag.ShowShortMessageOnly = false;
     var repo = RepositoryRepository.GetRepository(id);
     using (var browser = new RepositoryBrowser(Path.Combine(UserConfiguration.Current.Repositories, repo.Name)))
     {
         var model = browser.GetCommitDetail(commit);
         model.Name = repo.Name;
         model.Logo = new RepositoryLogoDetailModel(repo.Logo);
         return View(model);
     }
 }
开发者ID:forgetz,项目名称:Bonobo-Git-Server,代码行数:13,代码来源:RepositoryController.cs


示例15: Commits

        public ActionResult Commits(string id, string encodedName)
        {
            ViewBag.ID = id;
            if (!String.IsNullOrEmpty(id))
            {
                using (var browser = new RepositoryBrowser(Path.Combine(UserConfiguration.Current.Repositories, id)))
                {
                    var name = PathEncoder.Decode(encodedName);
                    string referenceName;
                    var commits = browser.GetCommits(name, out referenceName);
                    PopulateBranchesData(browser, referenceName);
                    return View(new RepositoryCommitsModel { Commits = commits, Name = id });
                }
            }

            return View();
        }
开发者ID:pofman,项目名称:Bonobo-Git-Server,代码行数:17,代码来源:RepositoryController.cs


示例16: Commits

        public ActionResult Commits(string id, string encodedName, int page = 1)
        {
            page = page >= 1 ? page : 1;
            
            ViewBag.ID = id;
            ViewBag.ShowShortMessageOnly = true;
            if (!String.IsNullOrEmpty(id))
            {
                using (var browser = new RepositoryBrowser(Path.Combine(UserConfiguration.Current.Repositories, id)))
                {
                    var name = PathEncoder.Decode(encodedName);
                    string referenceName;
                    int totalCount;
                    var commits = browser.GetCommits(name, page, 10, out referenceName, out totalCount);
                    PopulateBranchesData(browser, referenceName);
                    ViewBag.TotalCount = totalCount;
                    return View(new RepositoryCommitsModel { Commits = commits, Name = id });
                }
            }

            return View();
        }
开发者ID:psiborg,项目名称:Bonobo-Git-Server,代码行数:22,代码来源:RepositoryController.cs


示例17: Blame

        public ActionResult Blame(Guid id, string encodedName, string encodedPath)
        {
            ViewBag.ID = id;
            ViewBag.ShowShortMessageOnly = true;
            var repo = RepositoryRepository.GetRepository(id);
            using (var browser = new RepositoryBrowser(Path.Combine(UserConfiguration.Current.Repositories, repo.Name)))
            {
                var name = PathEncoder.Decode(encodedName);
                var path = PathEncoder.Decode(encodedPath);
                string referenceName;
                var model = browser.GetBlame(name, path, out referenceName);
                model.Logo = new RepositoryLogoDetailModel(repo.Logo);
                PopulateBranchesData(browser, referenceName);
                PopulateAddressBarData(path);

                return View(model);
            }
        }
开发者ID:forgetz,项目名称:Bonobo-Git-Server,代码行数:18,代码来源:RepositoryController.cs


示例18: Tags

        public ActionResult Tags(Guid id, string encodedName, int page = 1)
        {
            page = page >= 1 ? page : 1;

            ViewBag.ID = id;
            ViewBag.ShowShortMessageOnly = true;
            var repo = RepositoryRepository.GetRepository(id);
            using (var browser = new RepositoryBrowser(Path.Combine(UserConfiguration.Current.Repositories, repo.Name)))
            {
                var name = PathEncoder.Decode(encodedName);
                string referenceName;
                int totalCount;
                var commits = browser.GetTags(name, page, 10, out referenceName, out totalCount);
                PopulateBranchesData(browser, referenceName);
                ViewBag.TotalCount = totalCount;
                return View(new RepositoryCommitsModel {
                    Commits = commits,
                    Name = repo.Name,
                    Logo = new RepositoryLogoDetailModel(repo.Logo)
                });
            }
        }
开发者ID:forgetz,项目名称:Bonobo-Git-Server,代码行数:22,代码来源:RepositoryController.cs


示例19: Raw

        public ActionResult Raw(Guid id, string encodedName, string encodedPath, bool display = false)
        {
            ViewBag.ID = id;

            var repo = RepositoryRepository.GetRepository(id);
            using (var browser = new RepositoryBrowser(Path.Combine(UserConfiguration.Current.Repositories, repo.Name)))
            {
                var name = PathEncoder.Decode(encodedName);
                var path = PathEncoder.Decode(encodedPath);
                string referenceName;
                var model = browser.BrowseBlob(name, path, out referenceName);
                model.Logo = new RepositoryLogoDetailModel(repo.Logo);

                if (!display)
                {
                    return File(model.Data, "application/octet-stream", model.Name);
                }
                if (model.IsText)
                {
                    return Content(model.Text, "text/plain", model.Encoding);
                }
                if (model.IsImage)
                {
                    return File(model.Data, MimeTypeMap.GetMimeType(Path.GetExtension(model.Name.ToLower())), model.Name);
                }
            }

            return HttpNotFound();
        }
开发者ID:forgetz,项目名称:Bonobo-Git-Server,代码行数:29,代码来源:RepositoryController.cs


示例20: History

 public ActionResult History(Guid id, string encodedPath, string encodedName)
 {
     ViewBag.ID = id;
     ViewBag.ShowShortMessageOnly = true;
     var repo = RepositoryRepository.GetRepository(id);
     using (var browser = new RepositoryBrowser(Path.Combine(UserConfiguration.Current.Repositories, repo.Name)))
     {
         var path = PathEncoder.Decode(encodedPath);
         var name = PathEncoder.Decode(encodedName);
         string referenceName;
         var commits = browser.GetHistory(path, name, out referenceName);
         return View(new RepositoryCommitsModel {
             Commits = commits,
             Name = repo.Name,
             Logo = new RepositoryLogoDetailModel(repo.Logo)
         });
     }
 }
开发者ID:forgetz,项目名称:Bonobo-Git-Server,代码行数:18,代码来源:RepositoryController.cs



注:本文中的RepositoryBrowser类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# RepositoryFactory类代码示例发布时间:2022-05-24
下一篇:
C# Repository类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap