enable nullables
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>net8.0</TargetFrameworks>
|
<TargetFrameworks>net8.0</TargetFrameworks>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, Channels
|
|||||||
{
|
{
|
||||||
// E v e n t s
|
// E v e n t s
|
||||||
|
|
||||||
public event UpdateClientStatusChangedEventHandler OnStatusChanged;
|
public event UpdateClientStatusChangedEventHandler? OnStatusChanged;
|
||||||
|
|
||||||
// F i e l d s
|
// F i e l d s
|
||||||
|
|
||||||
@@ -18,8 +18,8 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, Channels
|
|||||||
public string UpdateUrl { get; private set; } = updateUrl;
|
public string UpdateUrl { get; private set; } = updateUrl;
|
||||||
public AppVersion CurrentVersion { get; private set; } = currentVersion;
|
public AppVersion CurrentVersion { get; private set; } = currentVersion;
|
||||||
public Channels MinimumChannel { get; private set; } = (Channels)Math.Max((int)minimumChannel, (int)currentVersion.Channel);
|
public Channels MinimumChannel { get; private set; } = (Channels)Math.Max((int)minimumChannel, (int)currentVersion.Channel);
|
||||||
public UpdateInfo UpdateInfo { get; private set; } = null;
|
public UpdateInfo? UpdateInfo { get; private set; }
|
||||||
public UpdatePackageInfo UpdatePackageInfo { get; private set; } = null;
|
public UpdatePackageInfo? UpdatePackageInfo { get; private set; }
|
||||||
public string HostApplicationPath { get; set; } = string.Empty;
|
public string HostApplicationPath { get; set; } = string.Empty;
|
||||||
public string ApplicationName { get; set; } = string.Empty;
|
public string ApplicationName { get; set; } = string.Empty;
|
||||||
public bool InstallAsAdmin { get; set; } = false;
|
public bool InstallAsAdmin { get; set; } = false;
|
||||||
@@ -51,7 +51,7 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, Channels
|
|||||||
{
|
{
|
||||||
var latestVersion = await CheckForUpdate();
|
var latestVersion = await CheckForUpdate();
|
||||||
|
|
||||||
if (HasUpdates)
|
if (HasUpdates && latestVersion is not null)
|
||||||
await UpdateInteractive(latestVersion);
|
await UpdateInteractive(latestVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,14 +63,14 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, Channels
|
|||||||
|
|
||||||
// F e a t u r e s
|
// F e a t u r e s
|
||||||
|
|
||||||
public async Task<UpdateInfo> GetUpdateInfo()
|
public async Task<UpdateInfo?> GetUpdateInfo()
|
||||||
{
|
{
|
||||||
string str = await WebClient.GetStringAsync(UpdateUrl);
|
string str = await WebClient.GetStringAsync(UpdateUrl);
|
||||||
var info = UpdateInfo.Parse(str);
|
var info = UpdateInfo.Parse(str);
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<UpdatePackageInfo> CheckForUpdate()
|
private async Task<UpdatePackageInfo?> CheckForUpdate()
|
||||||
{
|
{
|
||||||
RaiseStatusChanged(UpdateStatus.Searching, UpdateStatusEvent.PreEvent);
|
RaiseStatusChanged(UpdateStatus.Searching, UpdateStatusEvent.PreEvent);
|
||||||
|
|
||||||
@@ -82,29 +82,26 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, Channels
|
|||||||
return CheckForUpdate(UpdateInfo);
|
return CheckForUpdate(UpdateInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
private UpdatePackageInfo CheckForUpdate(UpdateInfo updateInfo)
|
private UpdatePackageInfo? CheckForUpdate(UpdateInfo updateInfo)
|
||||||
{
|
{
|
||||||
UpdatePackageInfo foundPkgInfo = null;
|
|
||||||
var latestVersion = CurrentVersion;
|
var latestVersion = CurrentVersion;
|
||||||
|
|
||||||
foreach (UpdatePackageInfo pkgInfo in updateInfo.Packages)
|
foreach (UpdatePackageInfo pkgInfo in updateInfo.Packages)
|
||||||
{
|
{
|
||||||
if (pkgInfo.Version.Channel <= MinimumChannel && pkgInfo.Version > latestVersion)
|
if (pkgInfo.Version.Channel <= MinimumChannel && pkgInfo.Version > latestVersion)
|
||||||
{
|
{
|
||||||
foundPkgInfo = pkgInfo;
|
UpdatePackageInfo = pkgInfo;
|
||||||
latestVersion = pkgInfo.Version;
|
latestVersion = pkgInfo.Version;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdatePackageInfo = foundPkgInfo;
|
|
||||||
|
|
||||||
if (!RaiseStatusChanged(UpdateStatus.Searching, UpdateStatusEvent.PostEvent, true))
|
if (!RaiseStatusChanged(UpdateStatus.Searching, UpdateStatusEvent.PostEvent, true))
|
||||||
{
|
{
|
||||||
UpdatePackageInfo = null;
|
UpdatePackageInfo = null;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return foundPkgInfo;
|
return UpdatePackageInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> DownloadPackageAsync(UpdatePackageInfo package)
|
public async Task<bool> DownloadPackageAsync(UpdatePackageInfo package)
|
||||||
@@ -171,7 +168,7 @@ public class UpdateClient(string updateUrl, AppVersion currentVersion, Channels
|
|||||||
RaiseStatusChanged(UpdateStatus.Copying, UpdateStatusEvent.PreEvent);
|
RaiseStatusChanged(UpdateStatus.Copying, UpdateStatusEvent.PreEvent);
|
||||||
var dataPathDir = new DirectoryInfo(dataPath);
|
var dataPathDir = new DirectoryInfo(dataPath);
|
||||||
var destDir = new DirectoryInfo(HostApplicationPath);
|
var destDir = new DirectoryInfo(HostApplicationPath);
|
||||||
General.CopyFiles(dataPathDir, destDir);
|
Utils.CopyFiles(dataPathDir, destDir);
|
||||||
RaiseStatusChanged(UpdateStatus.Copying, UpdateStatusEvent.PostEvent);
|
RaiseStatusChanged(UpdateStatus.Copying, UpdateStatusEvent.PostEvent);
|
||||||
|
|
||||||
// Delete Package
|
// Delete Package
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>net8.0</TargetFrameworks>
|
<TargetFrameworks>net8.0</TargetFrameworks>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>annotations</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ public class UpdateInfo
|
|||||||
{
|
{
|
||||||
public List<UpdatePackageInfo> Packages { get; set; } = [];
|
public List<UpdatePackageInfo> Packages { get; set; } = [];
|
||||||
|
|
||||||
public static UpdateInfo Parse(string str)
|
public static UpdateInfo? Parse(string str)
|
||||||
{
|
{
|
||||||
return JsonConvert.DeserializeObject<UpdateInfo>(str);
|
return JsonConvert.DeserializeObject<UpdateInfo>(str);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ public class UpdateNotes
|
|||||||
[JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
|
[JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
|
||||||
public UpdateNotesMode Mode { get; set; } = UpdateNotesMode.None;
|
public UpdateNotesMode Mode { get; set; } = UpdateNotesMode.None;
|
||||||
|
|
||||||
public string ExternalUrl { get; set; }
|
public string? ExternalUrl { get; set; }
|
||||||
|
|
||||||
public string ContentUrl { get; set; }
|
public string? ContentUrl { get; set; }
|
||||||
|
|
||||||
[JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
|
[JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
|
||||||
public UpdateNotesContentType ContentType { get; set; } = UpdateNotesContentType.PlainText;
|
public UpdateNotesContentType ContentType { get; set; } = UpdateNotesContentType.PlainText;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
namespace Pilz.Updating;
|
namespace Pilz.Updating;
|
||||||
|
|
||||||
public class UpdatePackageInfo
|
public class UpdatePackageInfo(AppVersion version, string packagelink)
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string? Name { get; set; }
|
||||||
public AppVersion Version { get; set; }
|
public AppVersion Version { get; set; } = version;
|
||||||
public UpdateNotes Notes { get; } = new();
|
public UpdateNotes Notes { get; } = new();
|
||||||
public string Packagelink { get; set; }
|
public string Packagelink { get; set; } = packagelink;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user