BimId.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*-------------------------------------------------------------------------
  2. * 功能描述:BimId
  3. * 作者:xulisong
  4. * 创建时间: 2019/6/13 9:57:38
  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. namespace JBIM
  13. {
  14. /*
  15. * 定义BimId类,初始化相关ID类型的引用
  16. * 引入该类,是为了方便在Id这一类型上的扩展,毕竟它和普通的基本类型有所不同
  17. */
  18. /// <summary>
  19. /// bimId类
  20. /// </summary>
  21. public class BimId
  22. {
  23. public BimId(string id)
  24. {
  25. this.Id = id;
  26. }
  27. /// <summary>
  28. /// Id值
  29. /// </summary>
  30. public string Id { get; private set; }
  31. public override string ToString()
  32. {
  33. return Id?.ToString() ?? string.Empty;
  34. }
  35. public override bool Equals(object obj)
  36. {
  37. if (obj is BimId inputId)
  38. {
  39. return Id == inputId.Id;
  40. }
  41. return false;
  42. }
  43. public override int GetHashCode()
  44. {
  45. if (string.IsNullOrWhiteSpace(Id))
  46. {
  47. return 0;
  48. }
  49. return Id.GetHashCode();
  50. }
  51. public static bool operator ==(BimId a, BimId b)
  52. {
  53. if ((object)a == null)
  54. {
  55. return (object)b == null;
  56. }
  57. return a.Equals(b);
  58. }
  59. public static bool operator !=(BimId a, BimId b)
  60. {
  61. if ((object)a == null)
  62. {
  63. return ((object)b != null);
  64. }
  65. return !a.Equals(b);
  66. }
  67. }
  68. }