Esempio n. 1
0
        private static void DownloadAll(string[] args, CreatureDownloader creatureDownloader)
        {
            if (args.Length == 0)
            {
                ListOperations();
                return;
            }

            var file = args[0];

            var creatures = creatureDownloader.DownloadCreatures();

            SaveToFiile(file, creatures);
        }
Esempio n. 2
0
        private static void Download(string[] args, CreatureDownloader creatureDownloader)
        {
            if (args.Length < 2)
            {
                ListOperations();
                return;
            }

            var file = args[0];

            var monsters = creatureDownloader.ListMonsters();

            var urisOrNames = args
                              .Skip(1)
                              .Select(uriOrName =>
                                      Uri.IsWellFormedUriString(uriOrName, UriKind.Absolute) ?
                                      uriOrName :
                                      monsters.FirstOrDefault(monster => string.Equals(uriOrName, monster.Key, StringComparison.OrdinalIgnoreCase)).Value
                                      ?? throw new ArgumentException("Invalid monster name or uri."));

            var creatures = creatureDownloader.DownloadCreatures(urisOrNames.ToArray());

            SaveToFiile(file, creatures);
        }