Пример #1
0
        public virtual async Task LoadConfigRemote(IStringDownloader downloader)
        {
            var uri  = Tools.Transfer.JoinUri(Uri, Repository.ConfigFileName);
            var data = await downloader.DownloadAsync(uri).ConfigureAwait(false);

            Config = SyncEvilGlobal.Yaml.NewFromYaml <SixRepoConfig>(data);
            if (Config.Hosts.Length == 0)
            {
                Config.Hosts = new[] { Uri }
            }
            ;

            Servers = (await Config.Servers.SelectAsync(y => GetServer(y, downloader))).ToDictionary(x => x.Key,
                                                                                                     x => x.Value);
        }

        async Task <KeyValuePair <string, SixRepoServer> > GetServer(string y, IStringDownloader downloader)
        {
            var uri = GetUri(y);

            try {
                return(new KeyValuePair <string, SixRepoServer>(y,
                                                                SyncEvilGlobal.Yaml.NewFromYaml <SixRepoServer>(await downloader.DownloadAsync(uri).ConfigureAwait(false))));
            } catch (WebException e) {
                throw new TransferError(
                          $"Problem while trying to access: {uri.AuthlessUri()}\n{e.Message}", e);
            }
        }