HOS.AutoUpdater 1.0.0

using HOS.AutoUpdater; using System.Diagnostics; using System.Net.Http.Headers; using System.Text; using System.Text.Json;

namespace WinFormsApp1 { class VersionAuthenication : IHttpVersionResponseHandler, IHttpAuthenicationHandler { public void Invoke(HttpClient httpClient) { //httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", ""); //httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", EConvert.ToBase64String(ncoding.ASCII.GetBytes($":"))); }

    public Version Parse(string response)
    {
        var versionResult = JsonSerializer.Deserialize<VersionInfo>(response);
        return new Version(versionResult.AppVersion);
    }
    class VersionInfo
    {
        public string AppVersion { get; set; }
    }
}
class DownloadAuthenication : IHttpAuthenicationHandler
{
    public void Invoke(HttpClient httpClient)
    {
        //httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "");
        //httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", EConvert.ToBase64String(ncoding.ASCII.GetBytes($"{basicUserID}:{basicPassword}")));
    }
}
internal static class Program
{
    /// <summary>
    ///  The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main()
    {
        // To customize application configuration such as set high DPI settings or default font,
        // see https://aka.ms/applicationconfiguration.
        ApplicationConfiguration.Initialize();

        string versionInfo = "1.0.0";
        string versionFile = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "version.txt");
        if (System.IO.File.Exists(versionFile))
            versionInfo = System.IO.File.ReadAllText(versionFile);
        if (string.IsNullOrEmpty(versionInfo))
            versionInfo = "1.0.0";
        if (AutoUpdateManager.Start(new AutoUpdateInfo
        {
            InstalledVersion = new Version(versionInfo),
            CurrentVersion = new Version("1.0.0.1"),
            //VersionEndpoint = new VesionEndpointInfo
            //{
            //    Url = "https://localhost:7293/api/General/GetLatestFileVersionAsync",
            //    Authenication = new VersionAuthenication(),
            //    Response = new VersionAuthenication(),
            //    ApiArgument = new { AppID = "POS-TILL", Token="asdasdasd23zewfd" },
            //},
            DownloadEndpoint = new EndpointInfo()
            {
                Url = "https://localhost:7293/api/General/GetLatestFileAsync",
                Authenication = new DownloadAuthenication(),
                ApiArgument = new { AppID = "POS-TILL", Token = "asdasdasd23zewfd" },
            }
        }))
        {
            return;
        }

        Application.Run(new Form1());
    }
}

}

No packages depend on HOS.AutoUpdater.

.NET 6.0

  • No dependencies.

Version Downloads Last updated
1.0.0 124 3/17/2023