Utils erweitert

This commit is contained in:
BlubbFish 2018-08-02 21:24:44 +00:00
parent 0c092a0b4d
commit 2cb2fcead5
2 changed files with 20 additions and 0 deletions

View File

@ -4,6 +4,13 @@ namespace BlubbFish.Utils.IoT.Bots.Events {
public class ModulEventArgs : EventArgs { public class ModulEventArgs : EventArgs {
public ModulEventArgs() { 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 Address { get; protected set; }
public String Property { get; protected set; } public String Property { get; protected set; }
public String Value { get; protected set; } public String Value { get; protected set; }

View File

@ -1,4 +1,5 @@
using System; using System;
using System.ComponentModel;
using System.Reflection; using System.Reflection;
namespace BlubbFish.Utils.IoT.Bots { namespace BlubbFish.Utils.IoT.Bots {
@ -65,6 +66,18 @@ namespace BlubbFish.Utils.IoT.Bots {
#endregion #endregion
#region StringHelper #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) { public static String ToUpperLower(this String s) {
if (s.Length == 0) { if (s.Length == 0) {
return ""; return "";