Person.cs 966 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. namespace Jint.Tests.Runtime.Domain
  2. {
  3. public class Person : IPerson
  4. {
  5. public string Name { get; set; }
  6. public int Age { get; set; }
  7. public Type TypeProperty { get; set; } = typeof(Person);
  8. public override string ToString()
  9. {
  10. return Name;
  11. }
  12. protected bool Equals(Person other)
  13. {
  14. return Name == other.Name;
  15. }
  16. public override bool Equals(object obj)
  17. {
  18. if (ReferenceEquals(null, obj))
  19. {
  20. return false;
  21. }
  22. if (ReferenceEquals(this, obj))
  23. {
  24. return true;
  25. }
  26. if (obj.GetType() != GetType())
  27. {
  28. return false;
  29. }
  30. return Equals((Person) obj);
  31. }
  32. public override int GetHashCode()
  33. {
  34. return (Name != null ? Name.GetHashCode() : 0);
  35. }
  36. }
  37. }