本文整理汇总了C#中GitSharp.Repository.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Repository.Dispose方法的具体用法?C# Repository.Dispose怎么用?C# Repository.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GitSharp.Repository
的用法示例。
在下文中一共展示了Repository.Dispose方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsValid
/// <summary>
/// Checks if the directory given by the path is a valid git repository.
/// </summary>
/// <param name="path"></param>
/// <param name="bare"></param>
/// <returns>Returns true if the given path is a valid git repository, false otherwise.</returns>
public static bool IsValid(string path, bool bare)
{
if (!bare)
{
if (!Regex.IsMatch(path, "\\.git[/\\\\]?$"))
path = Path.Combine(path, ".git");
}
if (!DirExists(path))
return false;
if (!FileExists(Path.Combine(path, "HEAD")))
return false;
if (!FileExists(Path.Combine(path, "config")))
return false;
//if (!DirExists(Path.Combine(path, "description")))
// return false;
//if (!DirExists(Path.Combine(path, "hooks")))
// return false;
//if (!DirExists(Path.Combine(path, "info")))
// return false;
//if (!DirExists(Path.Combine(path, "info/exclude")))
// return false;
if (!DirExists(Path.Combine(path, "objects")))
return false;
if (!DirExists(Path.Combine(path, "objects/info")))
return false;
if (!DirExists(Path.Combine(path, "objects/pack")))
return false;
if (!DirExists(Path.Combine(path, "refs")))
return false;
if (!DirExists(Path.Combine(path, "refs/heads")))
return false;
if (!DirExists(Path.Combine(path, "refs/tags")))
return false;
Repository repo = null;
try
{
// let's see if it loads without throwing an exception
repo = new Repository(path);
}
catch (Exception)
{
return false;
}
finally
{
if (repo != null)
{
repo.Dispose();
}
}
return true;
}