diff options
| author | Eric Reed <ebr@mediabrowser3.com> | 2013-03-04 09:43:29 -0500 |
|---|---|---|
| committer | Eric Reed <ebr@mediabrowser3.com> | 2013-03-04 09:43:29 -0500 |
| commit | b4ca3a7ad94484fe73262a4de92c554e768ee891 (patch) | |
| tree | 21751cc3170fd1e9fd0974df059411ef4696a732 /MediaBrowser.ClickOnce/ApplicationUpdater.cs | |
| parent | 67b20fdf0f970041480b1ea7d08d80b72a394c51 (diff) | |
| parent | d3b9afef2f3895daf91056938a92d6f51c8c834b (diff) | |
Merge branch 'master' of https://github.com/MediaBrowser/MediaBrowser
Conflicts:
MediaBrowser.Controller/Providers/FanartBaseProvider.cs
MediaBrowser.Controller/Providers/Music/LastfmArtistProvider.cs
Diffstat (limited to 'MediaBrowser.ClickOnce/ApplicationUpdater.cs')
| -rw-r--r-- | MediaBrowser.ClickOnce/ApplicationUpdater.cs | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/MediaBrowser.ClickOnce/ApplicationUpdater.cs b/MediaBrowser.ClickOnce/ApplicationUpdater.cs deleted file mode 100644 index 29af406f1..000000000 --- a/MediaBrowser.ClickOnce/ApplicationUpdater.cs +++ /dev/null @@ -1,92 +0,0 @@ -using System; -using System.ComponentModel; -using System.Deployment.Application; -using System.Threading; -using System.Threading.Tasks; - -namespace MediaBrowser.ClickOnce -{ - /// <summary> - /// Class ApplicationUpdater - /// </summary> - public class ApplicationUpdater - { - /// <summary> - /// The _task completion source - /// </summary> - private TaskCompletionSource<AsyncCompletedEventArgs> _taskCompletionSource; - - /// <summary> - /// The _progress - /// </summary> - private IProgress<double> _progress; - - /// <summary> - /// Updates the application - /// </summary> - /// <param name="cancellationToken">The cancellation token.</param> - /// <param name="progress">The progress.</param> - /// <returns>Task{AsyncCompletedEventArgs}.</returns> - /// <exception cref="System.InvalidOperationException">Current deployment is not network deployed.</exception> - public Task<AsyncCompletedEventArgs> UpdateApplication(CancellationToken cancellationToken, IProgress<double> progress) - { - if (!ApplicationDeployment.IsNetworkDeployed) - { - throw new InvalidOperationException("Current deployment is not network deployed."); - } - - _progress = progress; - - _taskCompletionSource = new TaskCompletionSource<AsyncCompletedEventArgs>(); - - var deployment = ApplicationDeployment.CurrentDeployment; - - cancellationToken.Register(deployment.UpdateAsyncCancel); - - cancellationToken.ThrowIfCancellationRequested(); - - deployment.UpdateCompleted += deployment_UpdateCompleted; - deployment.UpdateProgressChanged += deployment_UpdateProgressChanged; - - deployment.UpdateAsync(); - - return _taskCompletionSource.Task; - } - - /// <summary> - /// Handles the UpdateCompleted event of the deployment control. - /// </summary> - /// <param name="sender">The source of the event.</param> - /// <param name="e">The <see cref="AsyncCompletedEventArgs" /> instance containing the event data.</param> - void deployment_UpdateCompleted(object sender, AsyncCompletedEventArgs e) - { - var deployment = ApplicationDeployment.CurrentDeployment; - - deployment.UpdateCompleted -= deployment_UpdateCompleted; - deployment.UpdateProgressChanged -= deployment_UpdateProgressChanged; - - if (e.Error != null) - { - _taskCompletionSource.SetException(e.Error); - } - else if (e.Cancelled) - { - _taskCompletionSource.SetCanceled(); - } - else - { - _taskCompletionSource.SetResult(e); - } - } - - /// <summary> - /// Handles the UpdateProgressChanged event of the deployment control. - /// </summary> - /// <param name="sender">The source of the event.</param> - /// <param name="e">The <see cref="DeploymentProgressChangedEventArgs" /> instance containing the event data.</param> - void deployment_UpdateProgressChanged(object sender, DeploymentProgressChangedEventArgs e) - { - _progress.Report(e.ProgressPercentage); - } - } -} |
