BimObject.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. /// 获取类型Type
  27. /// </summary>
  28. /// <returns></returns>
  29. protected string GetElementType()
  30. {
  31. var attributes= this.GetType().GetCustomAttributes(typeof(TypeDefinitonAttribute), true);
  32. string result = null;
  33. if (attributes.Any())
  34. {
  35. result=(attributes[0] as TypeDefinitonAttribute)?.GetTypeDefiniton();
  36. }
  37. if (string.IsNullOrEmpty(result))
  38. {
  39. result= TypeDefinitonUtil.GetTypeDefiniton(TypeDefinition.BimObject);
  40. }
  41. return result;
  42. }
  43. }
  44. }