ElementEqualityComparer.cs 628 B

123456789101112131415161718192021222324252627
  1. using Autodesk.Revit.DB;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace SAGA.RevitUtils
  8. {
  9. /// <summary>
  10. /// 元素相等比较器
  11. /// </summary>
  12. public class ElementEqualityComparer : IEqualityComparer<Element>
  13. {
  14. public bool Equals(Element x, Element y)
  15. {
  16. if (x == null || y == null)
  17. return false;
  18. return x.Id.IntegerValue == y.Id.IntegerValue;
  19. }
  20. public int GetHashCode(Element obj)
  21. {
  22. return obj.Id.IntegerValue;
  23. }
  24. }
  25. }