Skip to content

VersionManager

The VersionManager class is an abstract base class within the ByteCobra Updater framework, responsible for managing version information of software packages. This class provides the functionality to read and write local package information and to fetch the latest version information from a remote source. It serves as a key component in determining whether updates are needed by comparing local and remote version data, and it allows for platform-specific handling of version information.

Example Usage

To effectively use the VersionManager class, it should be subclassed with specific implementations for handling version information. Here's an example demonstrating how to extend the VersionManager class:

using ByteCobra.Updater.Models;
using System.Threading.Tasks;

namespace ByteCobra.Updater
{
    public class CustomVersionManager : VersionManager
    {
        public override PackageInfo? ReadLocalPackage()
        {
            // Implement logic to read the local package's version information
        }

        public override void WriteLocalPackage(PackageInfo package)
        {
            // Implement logic to write or update the local package's version information
        }

        public override async Task<Version?> GetRemoteVersionAsync(string applicationName, Platform platform)
        {
            // Implement logic to fetch the latest version information from a remote source
        }
    }
}

In this example, CustomVersionManager is a subclass of VersionManager tailored to specific needs. It provides concrete implementations for ReadLocalPackage, WriteLocalPackage, and GetRemoteVersionAsync. These methods allow for handling of version information in a way that is best suited for the application, ensuring accurate and efficient update processes.