ToolUtility.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using System;
  2. using System.Web;
  3. using System.Configuration;
  4. using System.Collections.Generic;
  5. using System.Reflection;
  6. using System.ComponentModel;
  7. namespace CB.Common
  8. {
  9. public class ToolUtility
  10. {
  11. /// <summary>
  12. /// 自动生成元素name前缀
  13. /// </summary>
  14. public static string FilterNamePrefix
  15. {
  16. get
  17. {
  18. return Utils.GetAppSeting("ElementName") + "_";
  19. }
  20. }
  21. /// <summary>
  22. /// 获取枚举的Description信息 
  23. /// </summary>
  24. /// <param name="obj"></param>
  25. /// <returns></returns>
  26. public static string GetEnumDescription<T>(string enumValue)
  27. {
  28. T obj = TypeConverter.StringToEnum<T>(enumValue, "0");
  29. string objName = obj.ToString();
  30. Type t = obj.GetType();
  31. FieldInfo fi = t.GetField(objName);
  32. DescriptionAttribute[] arrDesc = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
  33. return arrDesc[0].Description;
  34. }
  35. public static string GetAdvertJsPath(params object[] args)
  36. {
  37. var pathFormat = System.Configuration.ConfigurationManager.AppSettings["advertremotingpath"];
  38. if (string.IsNullOrEmpty(pathFormat))
  39. pathFormat = "http://www.55125.cn/{0}/{1}.{2}";
  40. return string.Format(pathFormat, args);
  41. }
  42. }
  43. }