From fca2575ab62bcc3f2c7e7f8ff7f5b275e2d9099c Mon Sep 17 00:00:00 2001 From: BlubbFish Date: Sun, 23 Apr 2017 21:07:41 +0000 Subject: [PATCH] [WP] Refactoring so its in common to C# --- OwnView.cs | 16 +++++++++------- Updater.cs | 19 +++++++++++++++++-- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/OwnView.cs b/OwnView.cs index 102e1a5..ae3285e 100644 --- a/OwnView.cs +++ b/OwnView.cs @@ -4,21 +4,23 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BlubbFish.Utils -{ - public abstract class OwnView - { +namespace BlubbFish.Utils { + public abstract class OwnView { + + protected OwnView() { + this.Init(); + } /// /// Called if the Oberver (Model) updates its View /// - abstract public void Update(); + public abstract void Update(); /// /// Called if view is viewed /// - abstract protected void Init(); + protected abstract void Init(); /// /// Called if Form is Disposed /// - abstract public void Dispose(); + public abstract void Dispose(); } } diff --git a/Updater.cs b/Updater.cs index 3a736b3..4a7a776 100644 --- a/Updater.cs +++ b/Updater.cs @@ -1,10 +1,12 @@  using System; +using System.IO; namespace BlubbFish.Utils { - public class Updater { + public class Updater : OwnObject { private static Updater instances; private String url; + private String[] versions; public class UpdaterEventArgs : EventArgs { public UpdaterEventArgs(Boolean hasUpdates, String message) { @@ -45,8 +47,18 @@ namespace BlubbFish.Utils { /// Set Path to check for Updates /// /// HTTP URI - public void SetPath(String url) { + public void SetPath(String url, String[] versions) { this.url = url; + this.versions = versions; + StreamWriter file = new StreamWriter("version.txt"); + file.BaseStream.SetLength(0); + file.BaseStream.Flush(); + file.BaseStream.Seek(0, SeekOrigin.Begin); + foreach (String version in versions) { + file.WriteLine(version); + } + file.Flush(); + file.Close(); } /// @@ -57,6 +69,9 @@ namespace BlubbFish.Utils { if(this.url == "") { throw new ArgumentException("You must set url first."); } + if(this.versions.Length == 0) { + throw new ArgumentException("You must set a Version number first."); + } if(this.UpdateResult == null) { throw new ArgumentNullException("You must attach an event first."); }