예제 #1
0
        public ClientService(IDownloadService downloadService, ILocalStorageService localStorageService,
                             IDownloader downloader, IFormatter serializationFormatter)
        {
            DownloadService        = downloadService;
            LocalStorageService    = localStorageService;
            Downloader             = downloader;
            SerializationFormatter = serializationFormatter;

            Groups = GroupUrls
                     .Connect()
                     .Transform(g => new Uri(g))
                     .TransformAsync(Load <Group>)
                     .AsObservableList();
            Repos = Groups
                    .Connect()
                    .TransformMany(g => g.RepoInfos.Select(r => new Uri(g.BaseUri, r.Uri)))
                    .TransformAsync(Load <Repo>)
                    .AsObservableList();
            Modpacks = Repos
                       .Connect()
                       .TransformMany(r => r.Modpacks)
                       .AsObservableList();
        }
예제 #2
0
 public ClientService(IDownloader downloader, IFormatter serializationFormatter, DirectoryInfo localStorage)
 {
     fileAccessService           = new FileAccessService(localStorage);
     this.downloader             = downloader;
     this.serializationFormatter = serializationFormatter;
     filesAvailable.Edit(l => { l.AddOrUpdate(fileAccessService.FilesAvailable()); });
     LogTo.Warning("Creating pipeline");
     Repos = GroupUrls.Connect()
             .Transform(g => new Uri(g))
             .TransformAsync(Load <Group>)
             .TransformMany(g => g.RepoInfos.Select(r => g.CombineBaseUri(r.Uri)), repoUri => repoUri)
             .TransformAsync(Load <Repo>)
             .OnItemUpdated((repo, _) => LogTo.Information("Repo from {url} has been loaded", repo.BaseUri))
             .AsObservableCache();
     d.Add(Repos);
     OnlineFiles = Repos.Connect()
                   .TransformMany(
         repo => repo.Files.Select(kvp => new OnlineFile(kvp.Key, repo.CombineBaseUri(kvp.Value))),
         of => of.FileSignature).AsObservableCache();
     d.Add(OnlineFiles);
     Modpacks = Repos.Connect()
                .TransformMany(r => r.Modpacks.Select(m => new Modpack(m)), m => m.Id).AsObservableCache();
     d.Add(Modpacks);
 }