Project Init

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Yaojia Wang
2025-11-02 23:55:18 +01:00
commit 014d62bcc2
169 changed files with 28867 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
namespace ColaFlow.Shared.Kernel.Common;
/// <summary>
/// Base class for all value objects
/// </summary>
public abstract class ValueObject
{
protected abstract IEnumerable<object> GetAtomicValues();
public override bool Equals(object? obj)
{
if (obj == null || obj.GetType() != GetType())
return false;
var other = (ValueObject)obj;
return GetAtomicValues().SequenceEqual(other.GetAtomicValues());
}
public override int GetHashCode()
{
return GetAtomicValues()
.Aggregate(1, (current, obj) =>
{
unchecked
{
return (current * 23) + (obj?.GetHashCode() ?? 0);
}
});
}
public static bool operator ==(ValueObject? a, ValueObject? b)
{
if (a is null && b is null)
return true;
if (a is null || b is null)
return false;
return a.Equals(b);
}
public static bool operator !=(ValueObject? a, ValueObject? b)
{
return !(a == b);
}
}