예제 #1
0
        /// <summary>
        /// Checks if there are updates for any of the installed mods and/or new dependencies to fetch.
        /// </summary>
        public static async Task <bool> CheckForModUpdatesAsync()
        {
            var manageModsViewModel = IoC.Get <ManageModsViewModel>();
            var allMods             = manageModsViewModel.Mods.Select(x => new PathGenericTuple <ModConfig>(x.ModConfigPath, (ModConfig)x.ModConfig)).ToArray();

            try
            {
                var updater       = new Updater(allMods);
                var updateDetails = await updater.GetUpdateDetails();

                if (updateDetails.HasUpdates())
                {
                    Application.Current.Dispatcher?.Invoke(() =>
                    {
                        var dialog = new ModUpdateDialog(updater, updateDetails);
                        dialog.ShowDialog();
                        return(true);
                    });
                }
            }
            catch (Exception e)
            {
                System.Windows.MessageBox.Show(e.Message + "|" + e.StackTrace);
                return(false);
            }

            return(false);
        }
예제 #2
0
        /// <summary>
        /// Checks if there are updates for any of the installed mods and/or new dependencies to fetch.
        /// </summary>
        public static async Task <bool> CheckForModUpdatesAsync()
        {
            if (!_hasInternetConnection)
            {
                return(false);
            }

            var modConfigService = IoC.Get <ModConfigService>();
            var allMods          = modConfigService.Mods.Select(x => new PathTuple <ModConfig>(x.Path, (ModConfig)x.Config)).ToArray();

            try
            {
                var updater       = new Updater(allMods, new UpdaterData(IoC.Get <AggregateNugetRepository>()));
                var updateDetails = await updater.GetUpdateDetails();

                if (updateDetails.HasUpdates())
                {
                    ActionWrappers.ExecuteWithApplicationDispatcher(() =>
                    {
                        var dialog = new ModUpdateDialog(updater, updateDetails);
                        dialog.ShowDialog();
                    });

                    return(true);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message + "|" + e.StackTrace);
                return(false);
            }

            return(false);
        }