Browse Source

Minor change.

pull/9239/head
maliming 5 years ago
parent
commit
a2497d5072
  1. 30
      framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/Distributed/AutoEntityDistributedEventSelectorListExtensions.cs

30
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/Distributed/AutoEntityDistributedEventSelectorListExtensions.cs

@ -26,7 +26,7 @@ namespace Volo.Abp.Domain.Entities.Events.Distributed
) )
); );
} }
/// <summary> /// <summary>
/// Adds a specific entity type and the types derived from that entity type. /// Adds a specific entity type and the types derived from that entity type.
/// </summary> /// </summary>
@ -49,18 +49,18 @@ namespace Volo.Abp.Domain.Entities.Events.Distributed
) )
); );
} }
public static bool Remove<TEntity>( /// <summary>
[NotNull] this IAutoEntityDistributedEventSelectorList selectors) where TEntity : IEntity /// Remove a specific entity type and the types derived from that entity type.
/// </summary>
/// <typeparam name="TEntity">Type of the entity</typeparam>
public static void Remove<TEntity>([NotNull] this IAutoEntityDistributedEventSelectorList selectors)
where TEntity : IEntity
{ {
Check.NotNull(selectors, nameof(selectors)); Check.NotNull(selectors, nameof(selectors));
var selectorName = "Entity:" + typeof(TEntity).FullName; var selectorName = "Entity:" + typeof(TEntity).FullName;
if (selectors.Any(s => s.Name == selectorName)) selectors.RemoveAll(s => s.Name == selectorName);
{
return selectors.RemoveAll(s => s.Name == selectorName).Count > 0;
}
return true;
} }
/// <summary> /// <summary>
@ -69,7 +69,7 @@ namespace Volo.Abp.Domain.Entities.Events.Distributed
public static void AddAll([NotNull] this IAutoEntityDistributedEventSelectorList selectors) public static void AddAll([NotNull] this IAutoEntityDistributedEventSelectorList selectors)
{ {
Check.NotNull(selectors, nameof(selectors)); Check.NotNull(selectors, nameof(selectors));
if (selectors.Any(s => s.Name == AllEntitiesSelectorName)) if (selectors.Any(s => s.Name == AllEntitiesSelectorName))
{ {
return; return;
@ -85,11 +85,11 @@ namespace Volo.Abp.Domain.Entities.Events.Distributed
public static void Add( public static void Add(
[NotNull] this IAutoEntityDistributedEventSelectorList selectors, [NotNull] this IAutoEntityDistributedEventSelectorList selectors,
string selectorName, string selectorName,
Func<Type, bool> predicate) Func<Type, bool> predicate)
{ {
Check.NotNull(selectors, nameof(selectors)); Check.NotNull(selectors, nameof(selectors));
if (selectors.Any(s => s.Name == selectorName)) if (selectors.Any(s => s.Name == selectorName))
{ {
throw new AbpException($"There is already a selector added before with the same name: {selectorName}"); throw new AbpException($"There is already a selector added before with the same name: {selectorName}");
@ -102,7 +102,7 @@ namespace Volo.Abp.Domain.Entities.Events.Distributed
) )
); );
} }
public static void Add( public static void Add(
[NotNull] this IAutoEntityDistributedEventSelectorList selectors, [NotNull] this IAutoEntityDistributedEventSelectorList selectors,
Func<Type, bool> predicate) Func<Type, bool> predicate)
@ -116,11 +116,11 @@ namespace Volo.Abp.Domain.Entities.Events.Distributed
{ {
Check.NotNull(selectors, nameof(selectors)); Check.NotNull(selectors, nameof(selectors));
Check.NotNull(name, nameof(name)); Check.NotNull(name, nameof(name));
return selectors.RemoveAll(s => s.Name == name).Count > 0; return selectors.RemoveAll(s => s.Name == name).Count > 0;
} }
public static bool IsMatch([NotNull] this IAutoEntityDistributedEventSelectorList selectors, Type entityType) public static bool IsMatch([NotNull] this IAutoEntityDistributedEventSelectorList selectors, Type entityType)
{ {
Check.NotNull(selectors, nameof(selectors)); Check.NotNull(selectors, nameof(selectors));

Loading…
Cancel
Save