Skip to content

Commit

Permalink
* Added a constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDead committed Mar 17, 2019
1 parent 0453c1e commit 50aa7f7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
4 changes: 2 additions & 2 deletions UpdateManager/Classes/Update.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ internal void SetApplicationVersion(Version version)
/// <returns>A boolean to represent whether there is an update available or not</returns>
internal bool CheckForUpdate()
{
Version update = new Version(MajorVersion, MinorVersion, BuildVersion, RevisionVersion);
int result = update.CompareTo(_applicationVersion);
int result = new Version(MajorVersion, MinorVersion, BuildVersion, RevisionVersion)
.CompareTo(_applicationVersion);
return result > 0;
}
}
Expand Down
21 changes: 18 additions & 3 deletions UpdateManager/Classes/UpdateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,23 @@ public UpdateManager(Version version, string updateUrl, StringVariables stringVa
_applicationVersion = new Version(version.Major, version.Minor, version.Build, version.Revision);

_update.SetApplicationVersion(_applicationVersion);
_stringVariables = stringVariables;
SetStringVariables(stringVariables);
}

/// <summary>
/// Initialize a new UpdateManager object
/// </summary>
/// <param name="version">Your application version</param>
/// <param name="updateUrl">The URL where your XML update file is located</param>
public UpdateManager(Version version, string updateUrl)
{
_updateUrl = updateUrl;

_update = new Update();
_applicationVersion = new Version(version.Major, version.Minor, version.Build, version.Revision);

_update.SetApplicationVersion(_applicationVersion);
SetStringVariables(new StringVariables());
}

/// <summary>
Expand All @@ -57,8 +73,7 @@ public async void CheckForUpdate(bool showErrors, bool showNoUpdates)
{
try
{
WebClient wc = new WebClient();
string xml = await wc.DownloadStringTaskAsync(_updateUrl);
string xml = await new WebClient().DownloadStringTaskAsync(_updateUrl);

XmlSerializer serializer = new XmlSerializer(_update.GetType());
using (MemoryStream stream = new MemoryStream())
Expand Down

0 comments on commit 50aa7f7

Please sign in to comment.