-
-
Notifications
You must be signed in to change notification settings - Fork 6
API and customizations
You can implement your own downloader for your Launcher, if needed. Just implement IDownloader
interface in your own class as following:
public sealed class MyDownloader : MHLab.Patch.Core.Client.IO.IDownloader
{
// The code to implement IDownloader
}
then inject it into the Updater/Repairer/PatcherUpdater:
// This is taken from Launcher.cs, Initialize method.
_updater = new Updater(_context);
_updater.Downloader = new MyDownloader();
_updater.Downloader.DownloadComplete += DownloadComplete;
_updater.Downloader.ProgressChanged += DownloadProgressChanged;
You can implement your own logger for your Launcher, if needed. Just implement ILogger
interface in your own class as following:
public sealed class MyLogger : MHLab.Patch.Core.Loggers.ILogger
{
// The code to implement ILogger
}
then inject it into the UpdatingContext:
// This is taken from Launcher.cs, Initialize method.
_context = new UpdatingContext(settings, progress);
_context.Logger = new MyLogger();
Normally the Launcher sample script automatically starts the updating process, but for your convenience (and for customization purposes) some methods are exposed.
var repairer = new Repairer(_context);
repairer.IsRepairNeeded();
// It will return true if a repair is needed
var updater = new Updater(_context);
updater.IsUpdateAvailable();
// It will return true if a patch is available
Also, the UpdatingContext
has the IsDirty
property: you can check if it is set on true. If it is, a restart is recommended.
If you call those methods before the UpdatingContext's
Initialize
, you will get an exception.
You can queue your custom update steps in the PATCH's updating pipeline. The UpdatingContext
exposes the RegisterUpdateStep
method. It accepts an IUpdater
(PatchUpdater
, Repairer
and Updater
are all IUpdater
and are all queued in the updating pipeline).
public sealed class MyUpdaterStep : IUpdater
{
// The code to implement IUpdater
}
_context.RegisterUpdaterStep(new MyUpdaterStep());
You can find the sample usage in Launcher.cs
and LauncherUpdater.cs
, in Initialize
method.
Remember that the order matters when you register an IUpdater: it is the same order they will execute. All steps are executed when you call _context.Update()
.
You can also register to the PerformedStep
event on _context.Runner.PerformedStep
. It is executed every time a step in the pipeline completes.