Created
June 3, 2013 12:35
-
-
Save codescribler/5697820 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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