Created
March 6, 2013 20:08
-
-
Save fearthecowboy/5102603 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 override ILocation GetLocation(string path) { | |
var parsedPath = Path.ParseWithContainer(path); | |
// strip off the azure: | |
/* | |
if (parsedPath.Scheme != string.Empty && parsedPath.Scheme != AzureDriveInfo.ProviderScheme) { | |
return AzureLocation.InvalidLocation; | |
}*/ | |
// is this just a empty location? | |
if (string.IsNullOrEmpty(parsedPath.HostAndPort)) { | |
NamespaceProvider = NamespaceProvider ?? this; | |
return AzureNamespace; | |
} | |
var byAccount = AddingDrives.Union(Drives).Select(each => each as AzureDriveInfo).Where(each => each.HostAndPort == parsedPath.HostAndPort || each.ActualHostAndPort == parsedPath.HostAndPort); | |
if (!byAccount.Any()) { | |
return AzureLocation.UnknownLocation; | |
} | |
var byContainer = byAccount.Where(each => each.ContainerName == parsedPath.Container); | |
var byFolder = byContainer.Where(each => each.Path.IsSubpath(parsedPath)).OrderByDescending(each => each.RootPath.Length); | |
var result = byFolder.FirstOrDefault() ?? byContainer.FirstOrDefault() ?? byAccount.FirstOrDefault(); | |
return new AzureLocation(result, parsedPath, null); | |
} | |
/* | |
private IEnumerable<AzureDriveInfo> GetByAccount(Path parsedPath) { | |
var drive = AddingDrives.Union(Drives).Select(each => each as AzureDriveInfo).First(e => string.IsNullOrEmpty(e.HostAndPort)); | |
}*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment