Exemplo n.º 1
0
        public static async Task <Squadron> Download([Title("URL eingeben (http://xwing-builder.co.uk/view/...)")] string url)
        {
            if (!string.IsNullOrEmpty(url))
            {
                try
                {
                    var name       = url.Split(new[] { "/" }, StringSplitOptions.RemoveEmptyEntries).Last();
                    var downloaded = await Download(new Uri(url));

                    var newSquadron = new Squadron {
                        Name = name, Url = url, Downloaded = downloaded
                    };

                    await App.Squadronspeicher.Store(newSquadron);

                    return(newSquadron);
                }
                catch (Exception e)
                {
                    await new MessageDialog(e.Message, "Fehler").ShowAsync();
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 2
0
        public async Task Store(Squadron squadron)
        {
            var filecontent = new StringBuilder();

            using (var writer = new StringWriter(filecontent))
            {
                writer.WriteLine(squadron.Name);
                writer.WriteLine(squadron.Url);
                writer.Write(squadron.Downloaded);
                writer.Flush();
            }
            await SaveOrUpdate(squadron.Name, filecontent.ToString(), Windows.Storage.CreationCollisionOption.FailIfExists);
        }
Exemplo n.º 3
0
 public async Task Remove(Squadron squadron)
 {
     await Delete(squadron.Name);
 }