Skip to content

Commit

Permalink
🎨 Minor code-cleanup
Browse files Browse the repository at this point in the history
* Favour expression bodies for single-statement methods
* Remove unused fields, properties, methods and usings
* Add #region block in Program.cs
  • Loading branch information
oliverbooth committed Jun 25, 2019
1 parent abf0d1b commit affa0b5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 46 deletions.
17 changes: 1 addition & 16 deletions VPUpdater/DownloadForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ namespace VPUpdater
#region Using Directives

using System;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Threading.Tasks;
using System.Windows.Forms;
using Properties;
using Version = SemVer.Version;
Expand All @@ -31,9 +27,7 @@ public partial class DownloadForm : Form
{
#region Fields

private string setupTempFile = "";
private readonly string[] commandLineArgs;
private readonly WebClient client = new WebClient();
private readonly Updater updater;
private readonly VirtualParadise virtualParadise;

Expand All @@ -51,7 +45,7 @@ public DownloadForm(string[] args)
// Store CLI args as DI to pass to VP
this.commandLineArgs = args;
this.virtualParadise = VirtualParadise.GetCurrent();
this.updater = new Updater(this.virtualParadise);
this.updater = new Updater();
}

#endregion
Expand Down Expand Up @@ -96,15 +90,6 @@ private void ButtonCancel_Click(object sender, EventArgs e)
Environment.Exit(0);
}

/// <summary>
/// Checks for a Virtual Paradise update.
/// </summary>
/// <returns>Returns <see langword="true"/> if the there is an updated and the user accepted, <see langword="false"/> otherwise.</returns>
private async Task<Version> CheckForUpdates()
{
return await this.updater.FetchLatest();
}

/// <summary>
/// Called when the form first loads.
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions VPUpdater/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@

namespace VPUpdater
{
#region Using Directives

using System;
using System.Linq;
using System.Windows.Forms;

#endregion

/// <summary>
/// Application entry class.
/// </summary>
Expand Down
31 changes: 4 additions & 27 deletions VPUpdater/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ namespace VPUpdater
using System.Net;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using AngleSharp;
using AngleSharp.Dom;
using AngleSharp.Io;
using Properties;
using SemVer = SemVer.Version;

Expand All @@ -35,11 +33,6 @@ public class Updater : IDisposable
{
#region Fields

/// <summary>
/// The <see cref="VirtualParadise"/> instance.
/// </summary>
private readonly VirtualParadise virtualParadise;

/// <summary>
/// The web client instance.
/// </summary>
Expand All @@ -52,19 +45,6 @@ public class Updater : IDisposable

#endregion

#region Constructors

/// <summary>
/// Initializes a new instance of the <see cref="Updater"/> class.
/// </summary>
/// <param name="virtualParadise">The <see cref="VirtualParadise"/> instance.</param>
public Updater(VirtualParadise virtualParadise)
{
this.virtualParadise = virtualParadise;
}

#endregion

#region Events

/// <summary>
Expand All @@ -79,16 +59,12 @@ public Updater(VirtualParadise virtualParadise)
/// <summary>
/// Cancels any updates in progress.
/// </summary>
public void Cancel()
{
public void Cancel() =>
this.webClient?.CancelAsync();
}

/// <inheritdoc/>
public void Dispose()
{
public void Dispose() =>
this.webClient?.Dispose();
}

/// <summary>
/// Downloads the link to the latest
Expand Down Expand Up @@ -173,7 +149,8 @@ public async Task Launch()
{
if (!File.Exists(this.setupPath))
{
throw new FileNotFoundException(String.Format(Resources.FileNotFound, Path.GetFileName(this.setupPath)));
throw new FileNotFoundException(
String.Format(Resources.FileNotFound, Path.GetFileName(this.setupPath)));
}

await Task.Run(() =>
Expand Down
4 changes: 1 addition & 3 deletions VPUpdater/VirtualParadise.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,8 @@ private static SemVer GetSemVerFromSystemVersion(SysVer version) =>
/// Launches Virtual Paradise.
/// </summary>
/// <param name="args">The command-line arguments.</param>
public void Launch(params string[] args)
{
public void Launch(params string[] args) =>
Process.Start(this.FileInfo.FullName, String.Join(" ", args));
}

#endregion
}
Expand Down

0 comments on commit affa0b5

Please sign in to comment.