Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save codescribler/5697820 to your computer and use it in GitHub Desktop.
Save codescribler/5697820 to your computer and use it in GitHub Desktop.
public class TestRootPathProvider : IRootPathProvider
{
private static string _cachedRootPath;
public string GetRootPath()
{
//return @"C:\Applications\51\DeliveryDateCalculator\StandAndDeliver\Views\Home\";
if (!string.IsNullOrEmpty(_cachedRootPath))
return _cachedRootPath;
var currentDirectory = new DirectoryInfo(Environment.CurrentDirectory);
bool rootPathFound = false;
while (!rootPathFound)
{
var directoriesContainingViewFolder = currentDirectory.GetDirectories(
"Views", SearchOption.AllDirectories);
if (directoriesContainingViewFolder.Any())
{
_cachedRootPath = directoriesContainingViewFolder.First().FullName;
rootPathFound = true;
}
currentDirectory = currentDirectory.Parent;
}
return _cachedRootPath;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment