using System;
using System.Configuration;
namespace EasyNet.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;
}
}
}