当前位置: 首页>>代码示例>>C#>>正文


C# RepositoryBrowser.BrowseTree方法代码示例

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


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

示例1: AddTreeToZip

        private static void AddTreeToZip(RepositoryBrowser browser, string name, string path, ZipFile outputZip)
        {
            string referenceName;
            var treeNode = browser.BrowseTree(name, path, out referenceName);

            foreach (var item in treeNode)
            {
                if (item.IsLink)
                {
                    outputZip.AddDirectoryByName(Path.Combine(item.TreeName, item.Path));
                }
                else if (!item.IsTree)
                {
                    string blobReferenceName;
                    var model = browser.BrowseBlob(item.TreeName, item.Path, out blobReferenceName);
                    outputZip.AddEntry(Path.Combine(item.TreeName, item.Path), model.Data);
                }
                else
                {
                    // recursive call
                    AddTreeToZip(browser, item.TreeName, item.Path, outputZip);
                }
            }
        }
开发者ID:jiangzm,项目名称:Bonobo-Git-Server,代码行数:24,代码来源:RepositoryController.cs

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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


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