Exemplo n.º 1
0
        public async Task LoadAsync(IStatus status)
        {
            var loadStatus = await statusController.CreateAsync(status, "Load stored data", false);

            var storedDataUri = getPathDelegate.GetPath(string.Empty, string.Empty);

            storedData = await serializedStorageController.DeserializePullAsync <ModelType>(storedDataUri, loadStatus);

            if (storedData == null)
            {
                storedData = new ModelType();
            }

            DataAvailable = true;

            await statusController.CompleteAsync(loadStatus, false);
        }
Exemplo n.º 2
0
        public async Task <IEnumerable <string> > ItemizeAsync(GameDetails gameDetails, IStatus status)
        {
            var enumerateGameDetailsFilesStatus = await statusController.CreateAsync(status, "Enumerate game details files");

            var gameDetailsFiles = new List <string>();

            var gameDetailsManualUrls = await itemizeGameDetailsManualUrlsDelegate.ItemizeAsync(gameDetails, status);

            var gameDetailsManualUrlsCount = gameDetailsManualUrls.Count();
            var gameDetailsResolvedUris    = await routingController.TraceRoutesAsync(
                gameDetails.Id,
                gameDetailsManualUrls,
                enumerateGameDetailsFilesStatus);

            // that means that routes information is incomplete and
            // it's not possible to map manualUrls to resolvedUrls
            if (gameDetailsManualUrlsCount != gameDetailsResolvedUris.Count)
            {
                await statusController.CompleteAsync(enumerateGameDetailsFilesStatus);

                throw new ArgumentException($"Product {gameDetails.Id} resolvedUris count doesn't match manualUrls count");
            }

            for (var ii = 0; ii < gameDetailsResolvedUris.Count; ii++)
            {
                // since we don't download all languages and operating systems
                // we don't have routes for each and every gameDetails uri
                // however the ones we have should represent expected files for that product
                if (string.IsNullOrEmpty(gameDetailsResolvedUris[ii]))
                {
                    continue;
                }

                //var localFileUri = Path.Combine(
                //    getDirectoryDelegate.GetDirectory(gameDetailsManualUrls.ElementAt(ii)),
                //getFilenameDelegate.GetFilename(gameDetailsResolvedUris[ii]));

                var localFilePath = getPathDelegate.GetPath(
                    gameDetailsManualUrls.ElementAt(ii),
                    gameDetailsResolvedUris[ii]);

                gameDetailsFiles.Add(localFilePath);
            }

            await statusController.CompleteAsync(enumerateGameDetailsFilesStatus);

            if (gameDetailsManualUrlsCount != gameDetailsFiles.Count)
            {
                throw new ArgumentException($"Product {gameDetails.Id} files count doesn't match manualUrls count");
            }

            return(gameDetailsFiles);
        }
 public string Format(string uri)
 {
     return(getPathDelegate.GetPath(
                string.Empty,
                Path.GetFileName((uri))));
 }