[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.Threading.Tasks;
namespace BlubbFish.Utils
{
public abstract class OwnView
{
namespace BlubbFish.Utils {
public abstract class OwnView {
protected OwnView() {
this.Init();
}
/// <summary>
/// Called if the Oberver (Model) updates its View
/// </summary>
abstract public void Update();
public abstract void Update();
/// <summary>
/// Called if view is viewed
/// </summary>
abstract protected void Init();
protected abstract void Init();
/// <summary>
/// Called if Form is Disposed
/// </summary>
abstract public void Dispose();
public abstract void Dispose();
}
}

View File

@ -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
/// </summary>
/// <param name="url">HTTP URI</param>
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();
}
/// <summary>
@ -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.");
}