Skip to content

Updater

The Updater class is an abstract base class designed for managing the update process of applications. It facilitates various aspects of updating such as checking for new versions, downloading patches, installing updates, and launching the application. Key components include Platform, VersionManager, Downloader, Installer, and Launcher, along with properties like ApplicationName and AutoRepair. This design allows extensibility and customization for different application types and update mechanisms.

Example Usage

Since Updater is an abstract class, it must be inherited and implemented according to specific application requirements. Below is an example of customizing the Updater class:

using ByteCobra.Updater.Client.Launchers;
using ByteCobra.Updater.Installers;

namespace ByteCobra.Updater.Updaters
{
    public class MyWindowsUpdater : Updater
    {
        public override Platform Platform => Platform.StandaloneWindows64;
        public override VersionManager VersionManager => WindowsVersionManager;
        protected virtual VersionManager WindowsVersionManager { get; }

        public override Downloader Downloader => WindowsDownloader;
        protected virtual Downloader WindowsDownloader { get; }

        public override Installer Installer => WindowsInstaller;
        protected virtual DirectoryInstaller WindowsInstaller { get; }

        public override Launcher Launcher => WindowsLauncher;
        protected virtual WindowsLauncher WindowsLauncher { get; }

        public MyWindowsUpdater(
            string applicationName, 
            VersionManager versionManager, 
            Downloader downloader, 
            DirectoryInstaller installer, 
            WindowsLauncher launcher) 
            : base(applicationName)
        {
            WindowsVersionManager = versionManager;
            WindowsDownloader = downloader;
            WindowsInstaller = installer;
            WindowsLauncher = launcher;
        }
    }
}

In this example, MyWindowsUpdater inherits from the Updater class and is specifically tailored for Windows applications. It defines the platform and utilizes specific implementations of VersionManager, Downloader, Installer, and Launcher. This customization ensures that the updater is suitable for the specific needs of Windows applications, providing a framework for efficient and streamlined update processes.

You have the flexibility to craft custom Updater classes tailored to your unique requirements.