Exemplo n.º 1
0
 private void CheckForUpdates()
 {
     Task.Factory.StartNew(() =>
     {
         try
         {
             var client     = new WebClient();
             var stream     = client.OpenRead("http://sircmpwn.github.com/Patchy/update.json");
             var serializer = new JsonSerializer();
             var update     = serializer.Deserialize <AutomaticUpdate>(new JsonTextReader(new StreamReader(stream)));
             stream.Close();
             if (update.Version > CurrentVersion)
             {
                 Dispatcher.BeginInvoke(new Action(() =>
                 {
                     var window = new UpdateSummaryWindow(update);
                     if (window.ShowDialog().Value)
                     {
                         if (Directory.Exists(Path.Combine(SettingsManager.SettingsPath, "update")))
                         {
                             Directory.Delete(Path.Combine(SettingsManager.SettingsPath, "update"), true);
                         }
                         if (window.DownloadOverHttp)
                         {
                             Task.Factory.StartNew(() => UpdateOverHttp(update));
                         }
                         else
                         {
                             var torrent = AddTorrent(new MagnetLink(update.MagnetLink), Path.Combine(SettingsManager.SettingsPath, "update"));
                             if (torrent != null)
                             {
                                 torrent.IsAutomaticUpdate = true;
                             }
                         }
                     }
                 }));
             }
         }
         catch { }
     });
 }
Exemplo n.º 2
0
 private void CheckForUpdates()
 {
     Task.Factory.StartNew(() =>
         {
             try
             {
                 var client = new WebClient();
                 var stream = client.OpenRead("http://sircmpwn.github.com/Patchy/update.json");
                 var serializer = new JsonSerializer();
                 var update = serializer.Deserialize<AutomaticUpdate>(new JsonTextReader(new StreamReader(stream)));
                 stream.Close();
                 if (update.Version > CurrentVersion)
                 {
                     Dispatcher.BeginInvoke(new Action(() =>
                         {
                             var window = new UpdateSummaryWindow(update);
                             if (window.ShowDialog().Value)
                             {
                                 if (Directory.Exists(Path.Combine(SettingsManager.SettingsPath, "update")))
                                     Directory.Delete(Path.Combine(SettingsManager.SettingsPath, "update"), true);
                                 var torrent = AddTorrent(new MagnetLink(update.MagnetLink), Path.Combine(SettingsManager.SettingsPath, "update"));
                                 if (torrent != null)
                                     torrent.OpenWhenComplete = true;
                             }
                         }));
                 }
             }
             catch { }
         });
 }