using System; using System.Collections.Generic; namespace BlubbFish.Utils.IoT.Connector { public abstract class ADataBackend { public abstract event MqttMessage MessageIncomming; public abstract event MqttMessage MessageSending; public delegate void MqttMessage(Object sender, MqttEventArgs e); public static ADataBackend GetInstance(Dictionary dictionary) { String object_sensor = "BlubbFish.Utils.IoT.Connector." + Char.ToUpper(dictionary["type"][0]) + dictionary["type"].Substring(1).ToLower(); Type t = null; try { t = Type.GetType(object_sensor, true); } catch (TypeLoadException) { throw new ArgumentException("settings.ini: " + dictionary["type"] + " is not a Connector"); } return (ADataBackend)t.GetConstructor(new Type[] { typeof(Dictionary) }).Invoke(new Object[] { dictionary }); } public abstract void Send(String topic, String data); public abstract void Dispose(); } public class MqttEventArgs : EventArgs { public MqttEventArgs() : base() { } public MqttEventArgs(String message, String topic) { this.Topic = topic; this.Message = message; this.Date = DateTime.Now; } public String Topic { get; private set; } public String Message { get; private set; } public DateTime Date { get; private set; } } }