private AvailableResourcesInfoContainer getDirServerInfoDict(string parentDirPath) { AvailableResourcesInfoContainer infoContainer = new AvailableResourcesInfoContainer(); // Dictionary<string, ResourceDescription> infoDict = new Dictionary<string, ResourceDescription>(); List <string> resourceNames = Directory.GetDirectories(parentDirPath) .Select(dirPath => new DirectoryInfo(dirPath).Name).ToList(); foreach (string resourceName in resourceNames) { string resourceDirPath = Path.Combine(parentDirPath, resourceName); List <string> versions = Directory.GetDirectories(resourceDirPath) .Select(path => new DirectoryInfo(path).Name).ToList(); versions.Sort(compareVersions); // first item in sorted list is latest version string latestVersion = versions[0]; string resourceFilePath = Path.Combine( parentDirPath, resourceName, latestVersion, resourceName ); infoContainer.resourceDescriptions[resourceName] = new AvailableResourcesInfoContainer.AvailableResourceDescription( resourceFileSize(parentDirPath, latestVersion, resourceName), latestVersion ); } return(infoContainer); }
public static AvailableResourcesInfoContainer getAvailableResources(string prefix, ResourceType resourceType) { string url = availableResourcesUrl(prefix, resourceType); string serialized; try { serialized = client.GetStringAsync(url).Result; } catch (System.Exception) { throw new NetworkUtilsException("Unable to get list of available resources from server"); } try { AvailableResourcesInfoContainer resources = AvailableResourcesInfoContainer.deserialize(serialized); return(resources); } catch (System.Exception) { throw new NetworkUtilsException("Unable to process server response to available resources request"); } }