$mermaidjs
Clean Architecture Demo
Loading...
Searching...
No Matches
ValueObject.cs
Go to the documentation of this file.
2
3public abstract class ValueObject
4{
5 protected abstract IEnumerable<object?> GetEqualityComponents();
6
7 public override bool Equals(object? obj)
8 {
9 if (obj is null || obj.GetType() != GetType())
10 return false;
11
12 var other = (ValueObject)obj;
13 return GetEqualityComponents().SequenceEqual(other.GetEqualityComponents());
14 }
15
16 public override int GetHashCode()
17 {
19 .Aggregate(0, (current, component) =>
20 HashCode.Combine(current, component));
21 }
22
23 public static bool operator ==(ValueObject? left, ValueObject? right)
24 => Equals(left, right);
25
26 public static bool operator !=(ValueObject? left, ValueObject? right)
27 => !Equals(left, right);
28}
IEnumerable< object?> GetEqualityComponents()
static bool operator!=(ValueObject? left, ValueObject? right)
override bool Equals(object? obj)
Definition ValueObject.cs:7
static bool operator==(ValueObject? left, ValueObject? right)