BimObject.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*-------------------------------------------------------------------------
  2. * 功能描述:BimObject
  3. * 作者:xulisong
  4. * 创建时间: 2019/6/12 10:36:34
  5. * 版本号:v1.0
  6. * -------------------------------------------------------------------------*/
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using JBIM.Common;
  13. using JBIM.Definition;
  14. namespace JBIM
  15. {
  16. [TypeDefiniton(TypeDefinition.BimObject)]
  17. public class BimObject
  18. {
  19. public BimObject()
  20. {
  21. ElementType = GetElementType();
  22. }
  23. public BimId Id { get; internal set; }
  24. public string ElementType { get; protected set; }
  25. /// <summary>
  26. /// 附加信息,预留
  27. /// </summary>
  28. public string Tag { get; set; }
  29. /// <summary>
  30. /// 获取类型Type
  31. /// </summary>
  32. /// <returns></returns>
  33. protected string GetElementType()
  34. {
  35. var attributes = this.GetType().GetCustomAttributes(typeof(TypeDefinitonAttribute), true);
  36. string result = null;
  37. if (attributes.Any())
  38. {
  39. result = (attributes[0] as TypeDefinitonAttribute)?.GetTypeDefiniton();
  40. }
  41. if (string.IsNullOrEmpty(result))
  42. {
  43. result = TypeDefinitonUtil.GetTypeDefiniton(TypeDefinition.BimObject);
  44. }
  45. return result;
  46. }
  47. }
  48. }