Person.cs 980 B

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