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 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; }

View File

@ -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 "";