本文整理汇总了C#中RepositoryBrowser.BrowseBlob方法的典型用法代码示例。如果您正苦于以下问题:C# RepositoryBrowser.BrowseBlob方法的具体用法?C# RepositoryBrowser.BrowseBlob怎么用?C# RepositoryBrowser.BrowseBlob使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RepositoryBrowser
的用法示例。
在下文中一共展示了RepositoryBrowser.BrowseBlob方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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(name, path);
return View(model);
}
}
return View();
}
示例3: 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);
}
}
}
示例4: 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);
}
}
}
示例5: Raw
public ActionResult Raw(string id, string encodedName, string encodedPath, bool display = false)
{
ViewBag.ID = id;
if (String.IsNullOrEmpty(id))
return HttpNotFound();
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);
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, FileDisplayHandler.GetMimeType(model.Name), model.Name);
}
}
return HttpNotFound();
}
示例6: Raw
public ActionResult Raw(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 model = browser.BrowseBlob(name, path, out referenceName);
return File(model.Data, "application/octet-stream", model.Name);
}
}
return View();
}
示例7: 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();
}
示例8: Blob
public ActionResult Blob(Guid id, string encodedName, string encodedPath)
{
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);
PopulateBranchesData(browser, referenceName);
PopulateAddressBarData(path);
return View(model);
}
}