diff --git a/Events/ModulEventArgs.cs b/Events/ModulEventArgs.cs index ee44173..915c0d7 100644 --- a/Events/ModulEventArgs.cs +++ b/Events/ModulEventArgs.cs @@ -4,6 +4,13 @@ namespace BlubbFish.Utils.IoT.Bots.Events { public class ModulEventArgs : EventArgs { public ModulEventArgs() { } + public ModulEventArgs(String addr, String prop, String val, String src) + { + this.Address = addr; + this.Property = prop; + this.Value = val; + this.Source = src; + } public String Address { get; protected set; } public String Property { get; protected set; } public String Value { get; protected set; } diff --git a/Helper.cs b/Helper.cs index 50d506b..0c4264f 100644 --- a/Helper.cs +++ b/Helper.cs @@ -1,4 +1,5 @@ using System; +using System.ComponentModel; using System.Reflection; namespace BlubbFish.Utils.IoT.Bots { @@ -65,6 +66,18 @@ namespace BlubbFish.Utils.IoT.Bots { #endregion #region StringHelper + public static String GetEnumDescription(Enum value) { + FieldInfo fi = value.GetType().GetField(value.ToString()); + + DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false); + + if (attributes != null && attributes.Length > 0) { + return attributes[0].Description; + } else { + return value.ToString(); + } + } + public static String ToUpperLower(this String s) { if (s.Length == 0) { return "";