Refactoring

This commit is contained in:
2019-11-24 20:12:35 +01:00
parent 737b98778a
commit 0877e6ffbb
16 changed files with 88 additions and 89 deletions
+7 -5
View File
@@ -19,9 +19,9 @@ namespace BlubbFish.Utils.IoT.JsonSensor {
this.GetBool = true;
this.GetFloat = 0.0f;
this.GetInt = 0;
this.topic = (settings.Keys.Contains("topic")) ? settings["topic"] : "";
this.topic = settings.Keys.Contains("topic") ? settings["topic"] : "";
this.settings = settings;
this.Title = (settings.Keys.Contains("title")) ? settings["title"] : "";
this.Title = settings.Keys.Contains("title") ? settings["title"] : "";
this.Name = name;
this.backend = backend;
this.backend.MessageIncomming += this.IncommingMqttMessage;
@@ -52,7 +52,7 @@ namespace BlubbFish.Utils.IoT.JsonSensor {
public static AJsonSensor GetInstance(Dictionary<String, ABackend> backends, Dictionary<String, String> settings, String name) {
String object_sensor = "BlubbFish.Utils.IoT.JsonSensor." + Char.ToUpper(settings["type"][0]) + settings["type"].Substring(1).ToLower();
Type t = null;
Type t;
try {
t = Type.GetType(object_sensor, true);
} catch(TypeLoadException) {
@@ -117,11 +117,13 @@ namespace BlubbFish.Utils.IoT.JsonSensor {
this.disposedValue = true;
}
}
~AJsonSensor() {
Dispose(false);
this.Dispose(false);
}
public void Dispose() {
Dispose(true);
this.Dispose(true);
GC.SuppressFinalize(this);
}
#endregion
+1 -3
View File
@@ -5,9 +5,7 @@ using BlubbFish.Utils.IoT.Events;
namespace BlubbFish.Utils.IoT.JsonSensor {
class Pir : AJsonSensor {
public Pir(Dictionary<String, String> settings, String name, ADataBackend backend) : base(settings, name, backend) {
this.Datatypes = Types.Bool;
}
public Pir(Dictionary<String, String> settings, String name, ADataBackend backend) : base(settings, name, backend) => this.Datatypes = Types.Bool;
protected override Boolean UpdateValue(BackendEvent e) {
this.GetBool = (e.Message.ToLower() == "on") ? true : false;
+1 -3
View File
@@ -5,9 +5,7 @@ using BlubbFish.Utils.IoT.Events;
namespace BlubbFish.Utils.IoT.JsonSensor {
class Switch : AJsonSensor {
public Switch(Dictionary<System.String, System.String> settings, String name, ADataBackend backend) : base(settings, name, backend) {
this.Datatypes = Types.Bool;
}
public Switch(Dictionary<String, String> settings, String name, ADataBackend backend) : base(settings, name, backend) => this.Datatypes = Types.Bool;
protected override Boolean UpdateValue(BackendEvent e) {
this.GetBool = (e.Message.ToLower() == "on") ? true : false;