diff --git a/Chapter-4-applying-tactical-domain-driven-design/Fitnet.Common/Fitnet.Common.Core/ValueObject.cs b/Chapter-4-applying-tactical-domain-driven-design/Fitnet.Common/Fitnet.Common.Core/ValueObject.cs index 041f4eb8..0a494757 100644 --- a/Chapter-4-applying-tactical-domain-driven-design/Fitnet.Common/Fitnet.Common.Core/ValueObject.cs +++ b/Chapter-4-applying-tactical-domain-driven-design/Fitnet.Common/Fitnet.Common.Core/ValueObject.cs @@ -1,4 +1,4 @@ -namespace EvolutionaryArchitecture.Fitnet.Common.Core; +namespace EvolutionaryArchitecture.Fitnet.Common.Core; public abstract class ValueObject : IEquatable { @@ -7,17 +7,8 @@ public abstract class ValueObject : IEquatable public bool Equals(ValueObject? other) => other is not null && GetType() == other.GetType() && IsSequenceEqual(other); - public override bool Equals(object? obj) - { - if (obj is null || obj.GetType() != GetType()) - { - return false; - } - - var other = (ValueObject)obj; - - return IsSequenceEqual(other); - } + public override bool Equals(object? obj) => + obj is ValueObject valueObject && Equals(valueObject); public override int GetHashCode() => GetEqualityComponents() .Aggregate(default(int), (current, obj) => HashCode.Combine(current, obj.GetHashCode()));