using System;
using System.Configuration;
namespace Easy4net.Common
{
///
/// 通用实用工具
///
public class CommonUtils
{
///
/// 用于字符串和枚举类型的转换
///
///
///
///
public static T EnumParse(string value)
{
try
{
return (T)Enum.Parse(typeof(T), value);
}
catch
{
throw new Exception("传入的值与枚举值不匹配。");
}
}
///
/// 根据传入的Key获取配置文件中的Value值
///
///
///
public static string GetConfigValueByKey(string Key)
{
return ConfigurationManager.AppSettings[Key];
}
///
/// 检测输入值是否为空
///
///
///
public static Boolean IsNullOrEmpty(Object value)
{
if (value == null)
return true;
if (String.IsNullOrEmpty(value.ToString()))
return true;
return false;
}
}
}