예제 #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()
    {
        if (!HasInternetConnection)
        {
            return(false);
        }

        var loaderConfig         = IoC.Get <LoaderConfig>();
        var modConfigService     = IoC.Get <ModConfigService>();
        var modUserConfigService = IoC.Get <ModUserConfigService>();

        try
        {
            var nugetFeeds       = IoC.Get <AggregateNugetRepository>().Sources.Select(x => x.SourceUrl).ToList();
            var resolverSettings = new CommonPackageResolverSettings()
            {
                AllowPrereleases = loaderConfig.ForceModPrereleases
            };
            var updaterData   = new UpdaterData(nugetFeeds, resolverSettings);
            var updater       = new Updater(modConfigService, modUserConfigService, updaterData);
            var updateDetails = await updater.GetUpdateDetailsAsync();

            if (updateDetails.HasUpdates())
            {
                Actions.SynchronizationContext.Send(_ =>
                {
                    Actions.ShowModUpdateDialog.Invoke(new ModUpdateDialogViewModel(updater, updateDetails));
                }, null);

                return(true);
            }
        }
        catch (Exception e)
        {
            Actions.SynchronizationContext.Send(_ =>
            {
                Actions.DisplayMessagebox?.Invoke(Resources.ErrorError.Get(), e.Message + "|" + e.StackTrace, new Actions.DisplayMessageBoxParams()
                {
                    StartupLocation = Actions.WindowStartupLocation.CenterScreen
                });
            }, null);

            return(false);
        }

        return(false);
    }
예제 #2
0
 /// <summary/>
 public UpdaterData(List <string> nugetFeeds, CommonPackageResolverSettings commonPackageResolverSettings)
 {
     NuGetFeeds = nugetFeeds;
     CommonPackageResolverSettings = commonPackageResolverSettings;
 }