本文整理汇总了C#中RepositoryBrowser类的典型用法代码示例。如果您正苦于以下问题:C# RepositoryBrowser类的具体用法?C# RepositoryBrowser怎么用?C# RepositoryBrowser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RepositoryBrowser类属于命名空间,在下文中一共展示了RepositoryBrowser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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);
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
}
示例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();
}
示例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);
}
}
}
示例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();
}
示例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);
}
示例12: PopulateBranchesData
private void PopulateBranchesData(RepositoryBrowser browser, string referenceName)
{
ViewData["referenceName"] = referenceName;
ViewData["branches"] = browser.GetBranches();
ViewData["tags"] = browser.GetTags();
}
示例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);
}
}
}
示例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);
}
}
示例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();
}