add mirror to github.com
This commit is contained in:
parent
73674548e3
commit
870d8d065b
12
README.md
12
README.md
@ -1,8 +1,10 @@
|
||||
# BlubbFish.Utils.IoT (Utils-IoT)
|
||||
Library contains utils for Iot
|
||||
|
||||
## Linking to
|
||||
### External
|
||||
# BlubbFish.Utils.IoT (Utils-IoT)
|
||||
Library contains utils for Iot
|
||||
|
||||
Maybe you find this Repo on Github. This is a mirror from [here](https://git.blubbfish.net/vs_utils/Utils-IoT).
|
||||
|
||||
## Linking to
|
||||
### External
|
||||
* [litjson](http://git.blubbfish.net/vs_librarys/litjson)
|
||||
|
||||
### Internal
|
||||
|
@ -1,47 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using BlubbFish.Utils.IoT.Events;
|
||||
|
||||
namespace BlubbFish.Utils.IoT.Connector {
|
||||
public abstract class ABackend {
|
||||
public enum BackendType {
|
||||
Data,
|
||||
User
|
||||
}
|
||||
public event BackendMessage MessageIncomming;
|
||||
public event BackendMessage MessageSending;
|
||||
public delegate void BackendMessage(Object sender, BackendEvent e);
|
||||
|
||||
protected Dictionary<String, String> settings;
|
||||
|
||||
public abstract Boolean IsConnected { get; }
|
||||
|
||||
public ABackend(Dictionary<String, String> settings) => this.settings = settings;
|
||||
|
||||
public static ABackend GetInstance(Dictionary<String, String> settings, BackendType ty) {
|
||||
if (settings.Count == 0) {
|
||||
return null;
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using BlubbFish.Utils.IoT.Events;
|
||||
|
||||
namespace BlubbFish.Utils.IoT.Connector {
|
||||
public abstract class ABackend {
|
||||
public enum BackendType {
|
||||
Data,
|
||||
User
|
||||
}
|
||||
public event BackendMessage MessageIncomming;
|
||||
public event BackendMessage MessageSending;
|
||||
public delegate void BackendMessage(Object sender, BackendEvent e);
|
||||
|
||||
protected Dictionary<String, String> settings;
|
||||
|
||||
public abstract Boolean IsConnected { get; }
|
||||
|
||||
public ABackend(Dictionary<String, String> settings) => this.settings = settings;
|
||||
|
||||
public static ABackend GetInstance(Dictionary<String, String> settings, BackendType ty) {
|
||||
if (settings.Count == 0) {
|
||||
return null;
|
||||
}
|
||||
String object_sensor = "BlubbFish.Utils.IoT.Connector." + ty.ToString() + "." + settings["type"].ToUpperLower() + ", " + "Connector" + ty.ToString() + settings["type"].ToUpperLower();
|
||||
try {
|
||||
Type t = Type.GetType(object_sensor, true);
|
||||
return (ABackend)t.GetConstructor(new Type[] { typeof(Dictionary<String, String>) }).Invoke(new Object[] { settings });
|
||||
} catch (TypeLoadException) {
|
||||
Console.Error.WriteLine("Configuration: " + settings["type"] + " is not a " + ty.ToString() + "Backend");
|
||||
return null;
|
||||
} catch (System.IO.FileNotFoundException) {
|
||||
Console.Error.WriteLine("Driver " + object_sensor + " could not load!");
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
Type t = Type.GetType(object_sensor, true);
|
||||
return (ABackend)t.GetConstructor(new Type[] { typeof(Dictionary<String, String>) }).Invoke(new Object[] { settings });
|
||||
} catch (TypeLoadException) {
|
||||
Console.Error.WriteLine("Configuration: " + settings["type"] + " is not a " + ty.ToString() + "Backend");
|
||||
return null;
|
||||
} catch (System.IO.FileNotFoundException) {
|
||||
Console.Error.WriteLine("Driver " + object_sensor + " could not load!");
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
Console.Error.WriteLine("Something bad Happend while Loading Connectior: "+e.Message);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void NotifyClientIncomming(BackendEvent value) => this.MessageIncomming?.Invoke(this, value);
|
||||
|
||||
protected void NotifyClientSending(BackendEvent value) => this.MessageSending?.Invoke(this, value);
|
||||
|
||||
public abstract void Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void NotifyClientIncomming(BackendEvent value) => this.MessageIncomming?.Invoke(this, value);
|
||||
|
||||
protected void NotifyClientSending(BackendEvent value) => this.MessageSending?.Invoke(this, value);
|
||||
|
||||
public abstract void Dispose();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user