DeterministicStringKey.cs 732 B

123456789101112131415161718192021222324252627282930
  1. using System;
  2. using System.Diagnostics.CodeAnalysis;
  3. namespace Spv.Generator
  4. {
  5. internal class DeterministicStringKey : IEquatable<DeterministicStringKey>
  6. {
  7. private string _value;
  8. public DeterministicStringKey(string value)
  9. {
  10. _value = value;
  11. }
  12. public override int GetHashCode()
  13. {
  14. return DeterministicHashCode.GetHashCode(_value);
  15. }
  16. public bool Equals(DeterministicStringKey other)
  17. {
  18. return _value == other._value;
  19. }
  20. public override bool Equals([NotNullWhen(true)] object obj)
  21. {
  22. return obj is DeterministicStringKey && Equals((DeterministicStringKey)obj);
  23. }
  24. }
  25. }