forked from OpenTabletDriver/OpenTabletDriver
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
269 additions
and
492 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using System.Collections.Immutable; | ||
|
||
namespace OpenTabletDriver.Desktop.Updater | ||
{ | ||
public record Update | ||
{ | ||
public Update(Version version, ImmutableArray<string> paths) | ||
{ | ||
Version = version; | ||
Paths = paths; | ||
} | ||
|
||
public Version Version { get; init; } | ||
|
||
/// <summary> | ||
/// Gets the paths of files/directories directly in the root of the update. | ||
/// </summary> | ||
public ImmutableArray<string> Paths { get; init; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,38 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace OpenTabletDriver.Desktop.Updater | ||
{ | ||
public interface IUpdater | ||
{ | ||
Task<bool> CheckForUpdates(); | ||
Task<UpdateInfo?> GetInfo(); | ||
Task InstallUpdate(); | ||
/// <summary> | ||
/// Checks if an update is available. | ||
/// </summary> | ||
/// <returns> | ||
/// Returns an <see cref="UpdateInfo"/> if an update is available, otherwise returns null. | ||
/// </returns> | ||
Task<UpdateInfo?> CheckForUpdates(); | ||
|
||
/// <summary> | ||
/// Installs an update. | ||
/// </summary> | ||
/// <param name="update">The update to install.</param> | ||
/// <returns>The result of installing the update.</returns> | ||
Task Install(Update update); | ||
|
||
/// <summary> | ||
/// Occurs when an update is being installed. | ||
/// </summary> | ||
event Action<Update> UpdateInstalling; | ||
|
||
/// <summary> | ||
/// Occurs when a rollback is created. This event provides the path to the rollback directory. | ||
/// </summary> | ||
event Action<string> RollbackCreated; | ||
|
||
/// <summary> | ||
/// Occurs when an update is installed. | ||
/// </summary> | ||
event Action<Update> UpdateInstalled; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
|
||
namespace OpenTabletDriver.Desktop.Updater | ||
{ | ||
public sealed class SerializedUpdateInfo | ||
{ | ||
public SerializedUpdateInfo(UpdateInfo updateInfo) | ||
{ | ||
Version = updateInfo.Version; | ||
} | ||
|
||
public Version Version { get; set; } = new Version(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,26 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace OpenTabletDriver.Desktop.Updater | ||
{ | ||
public record UpdateInfo(Version Version); | ||
public sealed class UpdateInfo | ||
{ | ||
private readonly Func<Task<Update>> _updateFactory; | ||
private Update? _update; | ||
|
||
public UpdateInfo(Func<Task<Update>> updateFactory) | ||
{ | ||
_updateFactory = updateFactory; | ||
} | ||
|
||
public Version Version { get; init; } = new Version(); | ||
|
||
public async Task<Update> GetUpdate() | ||
{ | ||
_update ??= await _updateFactory(); | ||
return _update; | ||
} | ||
|
||
public SerializedUpdateInfo ToSerializedUpdateInfo() => new(this); | ||
} | ||
} |
Oops, something went wrong.