PropertyCache.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /*-------------------------------------------------------------------------
  2. * 功能描述:PropertyCache
  3. * 作者:xulisong
  4. * 创建时间: 2019/6/17 10:04:51
  5. * 版本号:v1.0
  6. * -------------------------------------------------------------------------*/
  7. using System.Collections.Generic;
  8. using System.Reflection;
  9. namespace JBIM.Common
  10. {
  11. public static class PropertyCache
  12. {
  13. private static readonly Dictionary<string, PropertyInfo> m_CacheProperties = new Dictionary<string, PropertyInfo>();
  14. /// <summary>
  15. /// 设置指定键值的属性
  16. /// </summary>
  17. /// <param name="key"></param>
  18. /// <param name="propertyInfo"></param>
  19. public static void SetProperty(string key, PropertyInfo propertyInfo)
  20. {
  21. m_CacheProperties[key] = propertyInfo;
  22. }
  23. /// <summary>
  24. /// 获取指定键值的属性
  25. /// </summary>
  26. /// <param name="key"></param>
  27. /// <returns></returns>
  28. public static PropertyInfo GetProperty(string key)
  29. {
  30. m_CacheProperties.TryGetValue(key, out PropertyInfo result);
  31. return result;
  32. }
  33. }
  34. }