diff --git a/README.md b/README.md index 726a3d2..7550132 100644 --- a/README.md +++ b/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 diff --git a/Utils-IoT/Connector/ABackend.cs b/Utils-IoT/Connector/ABackend.cs index d0f899c..87981fd 100644 --- a/Utils-IoT/Connector/ABackend.cs +++ b/Utils-IoT/Connector/ABackend.cs @@ -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 settings; - - public abstract Boolean IsConnected { get; } - - public ABackend(Dictionary settings) => this.settings = settings; - - public static ABackend GetInstance(Dictionary 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 settings; + + public abstract Boolean IsConnected { get; } + + public ABackend(Dictionary settings) => this.settings = settings; + + public static ABackend GetInstance(Dictionary 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) }).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) }).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(); + } +}