[WP] Refactoring so its in common to C#

This commit is contained in:
BlubbFish 2017-04-23 21:07:41 +00:00
parent 0fe8437e0d
commit fca2575ab6
2 changed files with 26 additions and 9 deletions

View File

@ -4,21 +4,23 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace BlubbFish.Utils namespace BlubbFish.Utils {
{ public abstract class OwnView {
public abstract class OwnView
{ protected OwnView() {
this.Init();
}
/// <summary> /// <summary>
/// Called if the Oberver (Model) updates its View /// Called if the Oberver (Model) updates its View
/// </summary> /// </summary>
abstract public void Update(); public abstract void Update();
/// <summary> /// <summary>
/// Called if view is viewed /// Called if view is viewed
/// </summary> /// </summary>
abstract protected void Init(); protected abstract void Init();
/// <summary> /// <summary>
/// Called if Form is Disposed /// Called if Form is Disposed
/// </summary> /// </summary>
abstract public void Dispose(); public abstract void Dispose();
} }
} }

View File

@ -1,10 +1,12 @@
 
using System; using System;
using System.IO;
namespace BlubbFish.Utils { namespace BlubbFish.Utils {
public class Updater { public class Updater : OwnObject {
private static Updater instances; private static Updater instances;
private String url; private String url;
private String[] versions;
public class UpdaterEventArgs : EventArgs { public class UpdaterEventArgs : EventArgs {
public UpdaterEventArgs(Boolean hasUpdates, String message) { public UpdaterEventArgs(Boolean hasUpdates, String message) {
@ -45,8 +47,18 @@ namespace BlubbFish.Utils {
/// Set Path to check for Updates /// Set Path to check for Updates
/// </summary> /// </summary>
/// <param name="url">HTTP URI</param> /// <param name="url">HTTP URI</param>
public void SetPath(String url) { public void SetPath(String url, String[] versions) {
this.url = url; 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();
} }
/// <summary> /// <summary>
@ -57,6 +69,9 @@ namespace BlubbFish.Utils {
if(this.url == "") { if(this.url == "") {
throw new ArgumentException("You must set url first."); 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) { if(this.UpdateResult == null) {
throw new ArgumentNullException("You must attach an event first."); throw new ArgumentNullException("You must attach an event first.");
} }