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