From 75dd6e8e5ecf35cf4d762b29b76e2e1cfc1ac3ce Mon Sep 17 00:00:00 2001 From: BlubbFish <git@blubbfish.net> Date: Thu, 20 Apr 2017 15:09:37 +0000 Subject: [PATCH] [NF] First try to create an Autoupdater --- OwnObject.cs | 2 +- Updater.cs | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 Updater.cs diff --git a/OwnObject.cs b/OwnObject.cs index be98b00..6b6c586 100644 --- a/OwnObject.cs +++ b/OwnObject.cs @@ -7,7 +7,7 @@ namespace BlubbFish.Utils { abstract public class OwnObject { - public class LogObject { + public struct LogObject { public LogObject(DateTime date, String location, String message, LogLevel level) { this.Date = date; this.Location = location; diff --git a/Updater.cs b/Updater.cs new file mode 100644 index 0000000..95001ab --- /dev/null +++ b/Updater.cs @@ -0,0 +1,66 @@ + +using System; + +namespace BlubbFish.Utils { + public class Updater { + private static Updater instances; + private String url; + + public delegate void UpdateStatus(Boolean hasUpdates, String message); + + public event UpdateStatus UpdateResult; + + private Updater() { } + + /// <summary> + /// Get Instance of Updater + /// </summary> + public static Updater Instance { + get { + if(instances == null) { + instances = new Updater(); + } + return instances; + } + } + + /// <summary> + /// Waits for the Result of the Updater thread. + /// </summary> + public void WaitForExit() { + throw new NotImplementedException(); + } + + /// <summary> + /// Set Path to check for Updates + /// </summary> + /// <param name="url">HTTP URI</param> + public void SetPath(String url) { + this.url = url; + } + + /// <summary> + /// Check for Updates + /// </summary> + /// <exception cref="ArgumentException"></exception> + public void Check() { + if(this.url == "") { + throw new ArgumentException("You must set url first."); + } + if(this.UpdateResult == null) { + throw new ArgumentNullException("You must attach an event first."); + } + } + + /// <summary> + /// Update the file + /// </summary> + /// <param name="filename">The filename of the targetfile</param> + /// <param name="url">The url of the sourcefile</param> + /// <param name="afterExit">Updates the Programm after it has been closed</param> + /// <returns></returns> + public Boolean Update(String filename, String url, Boolean afterExit = true) { + return true; + } + } +}