Merge pull request #16204 from abpframework/IsValueObjectPredicate

Make `IsValueObject` check customizable.
pull/16216/head
liangshiwei 3 years ago committed by GitHub
commit 6f27b26692
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -123,10 +123,17 @@ public static class EntityHelper
return typeof(IEntity).IsAssignableFrom(type);
}
public static Func<Type, bool> IsValueObjectPredicate = type => typeof(ValueObject).IsAssignableFrom(type);
public static bool IsValueObject([NotNull] Type type)
{
Check.NotNull(type, nameof(type));
return typeof(ValueObject).IsAssignableFrom(type);
return IsValueObjectPredicate(type);
}
public static bool IsValueObject(object obj)
{
return obj != null && IsValueObject(obj.GetType());
}
public static void CheckEntity([NotNull] Type type)

@ -93,7 +93,7 @@ public class EntityHistoryHelper : IEntityHistoryHelper, ITransientDependency
}
var entityId = GetEntityId(entity);
if (entityId == null && changeType != EntityChangeType.Created && !(entity is ValueObject))
if (entityId == null && changeType != EntityChangeType.Created && !EntityHelper.IsValueObject(entity))
{
return null;
}
@ -151,7 +151,7 @@ public class EntityHistoryHelper : IEntityHistoryHelper, ITransientDependency
return keys.JoinAsString(",");
}
if (entityAsObj is ValueObject)
if (EntityHelper.IsValueObject(entityAsObj))
{
return null;
}

Loading…
Cancel
Save