コード例 #1
0
ファイル: Updater.cs プロジェクト: DeaTh-G/Reloaded-II
        /// <summary>
        /// Updates all of the mods.
        /// </summary>
        /// <param name="summary">Summary of updates returned from <see cref="GetUpdateDetails"/></param>
        /// <param name="progressHandler">Event to receive information about the overall download and extract progress of all mods combined.</param>
        public async Task Update(ModUpdateSummary summary, IProgress <double> progressHandler = null)
        {
            // Guard against null.
            int pairCount = summary.ResolverManagerResultPairs.Count;

            var               completeMods             = new Box <int>(0);
            float             completeModSegmentLength = (float)1 / pairCount;
            Progress <double> totalProgressHandler     = null;

            if (progressHandler != null)
            {
                totalProgressHandler = new Progress <double>(progress =>
                {
                    progressHandler.Report((progress / pairCount) + (completeModSegmentLength * completeMods.Value));
                });
            }

            foreach (var pair in summary.ResolverManagerResultPairs)
            {
                var manager = pair.Manager;
                var version = pair.Result.LastVersion;
                await manager.PrepareUpdateAsync(version, totalProgressHandler);

                manager.LaunchUpdater(version, false);
                pair.Resolver.PostUpdateCallback(true);
                completeMods.Value += 1;
            }
        }
コード例 #2
0
 public ModUpdateDialogViewModel(Updater updater, ModUpdateSummary summary)
 {
     Updater    = updater;
     Summary    = summary;
     UpdateInfo = Summary.GetUpdateInfo();
     TotalSize  = Summary.GetTotalSize();
 }
コード例 #3
0
 /// <summary/>
 public ModUpdateDialogViewModel(Updater updater, ModUpdateSummary summary)
 {
     Updater        = updater;
     Summary        = summary;
     UpdateInfo     = Summary.GetUpdateInfo();
     TotalSize      = UpdateInfo.Sum(x => x.UpdateSize);
     SelectedUpdate = UpdateInfo[0];
     CanDownload    = true;
 }
コード例 #4
0
    /// <summary>
    /// Updates all of the mods.
    /// </summary>
    /// <param name="summary">Summary of updates returned from <see cref="GetUpdateDetailsAsync"/></param>
    /// <param name="progressHandler">Event to receive information about the overall download and extract progress of all mods combined.</param>
    public async Task Update(ModUpdateSummary summary, IProgress <double>?progressHandler = null)
    {
        // Guard against null.
        var progressMixer      = new ProgressSlicer(progressHandler);
        var singleItemProgress = 1.0 / summary.ManagerModResultPairs.Count;

        for (var x = 0; x < summary.ManagerModResultPairs.Count; x++)
        {
            var slice   = progressMixer.Slice(singleItemProgress);
            var pair    = summary.ManagerModResultPairs[x];
            var manager = pair.Manager;
            var version = pair.Result.LastVersion;

            await manager.PrepareUpdateAsync(version !, slice);

            await manager.StartUpdateAsync(version !, new OutOfProcessOptions(), new UpdateOptions()
            {
                CleanupAfterUpdate = true
            });

            manager.Dispose();
        }
    }
コード例 #5
0
 public ModUpdateDialog(Updater updater, ModUpdateSummary summary)
 {
     InitializeComponent();
     ViewModel = new ModUpdateDialogViewModel(updater, summary);
 }