diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Values/ValueObject.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Values/ValueObject.cs
index dccd1c0206..ea84b41792 100644
--- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Values/ValueObject.cs
+++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Values/ValueObject.cs
@@ -1,98 +1,61 @@
-using System;
+using System.Collections.Generic;
using System.Linq;
-using System.Reflection;
namespace Volo.Abp.Domain.Values
{
- //Inspired from https://blogs.msdn.microsoft.com/cesardelatorre/2011/06/06/implementing-a-value-object-base-class-supertype-patternddd-patterns-related/
-
- ///
- /// Base class for value objects.
- ///
- /// The type of the value object.
- public abstract class ValueObject : IEquatable
- where TValueObject : ValueObject
+ //Inspired from https://docs.microsoft.com/en-us/dotnet/standard/microservices-architecture/microservice-ddd-cqrs-patterns/implement-value-objects
+
+ public abstract class ValueObject
{
- public bool Equals(TValueObject other)
+ protected static bool EqualOperator(ValueObject left, ValueObject right)
{
- if ((object)other == null)
+ if (ReferenceEquals(left, null) ^ ReferenceEquals(right, null))
{
return false;
}
+ return ReferenceEquals(left, null) || left.Equals(right);
+ }
- var publicProperties = GetType().GetTypeInfo().GetProperties();
- if (!publicProperties.Any())
- {
- return true;
- }
-
- return publicProperties.All(property => Equals(property.GetValue(this, null), property.GetValue(other, null)));
+ protected static bool NotEqualOperator(ValueObject left, ValueObject right)
+ {
+ return !(EqualOperator(left, right));
}
+ protected abstract IEnumerable