mirror of https://github.com/abpframework/abp.git
Browse Source
Added EntityHistorySelectorList option. Renamed AuditingOptions to AbpAuditingOptions. Ignored some Identity properties for audit logging.pull/395/head
13 changed files with 131 additions and 17 deletions
@ -0,0 +1,12 @@ |
|||
using System.Collections.Generic; |
|||
|
|||
namespace Volo.Abp.Auditing |
|||
{ |
|||
internal class EntityHistorySelectorList : List<NamedTypeSelector>, IEntityHistorySelectorList |
|||
{ |
|||
public bool RemoveByName(string name) |
|||
{ |
|||
return RemoveAll(s => s.Name == name) > 0; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
using System.Collections.Generic; |
|||
|
|||
namespace Volo.Abp.Auditing |
|||
{ |
|||
public interface IEntityHistorySelectorList : IList<NamedTypeSelector> |
|||
{ |
|||
/// <summary>
|
|||
/// Removes a selector by name.
|
|||
/// </summary>
|
|||
/// <param name="name"></param>
|
|||
/// <returns></returns>
|
|||
bool RemoveByName(string name); |
|||
} |
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
using System; |
|||
|
|||
namespace Volo.Abp |
|||
{ |
|||
/// <summary>
|
|||
/// Used to represent a named type selector.
|
|||
/// </summary>
|
|||
public class NamedTypeSelector |
|||
{ |
|||
/// <summary>
|
|||
/// Name of the selector.
|
|||
/// </summary>
|
|||
public string Name { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Predicate.
|
|||
/// </summary>
|
|||
public Func<Type, bool> Predicate { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Creates new <see cref="NamedTypeSelector"/> object.
|
|||
/// </summary>
|
|||
/// <param name="name">Name</param>
|
|||
/// <param name="predicate">Predicate</param>
|
|||
public NamedTypeSelector(string name, Func<Type, bool> predicate) |
|||
{ |
|||
Name = name; |
|||
Predicate = predicate; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
|
|||
namespace Volo.Abp |
|||
{ |
|||
public static class NamedTypeSelectorListExtensions |
|||
{ |
|||
/// <summary>
|
|||
/// Add list of types to the list.
|
|||
/// </summary>
|
|||
/// <param name="list">List of NamedTypeSelector items</param>
|
|||
/// <param name="name">An arbitrary but unique name (can be later used to remove types from the list)</param>
|
|||
/// <param name="types"></param>
|
|||
public static void Add(this IList<NamedTypeSelector> list, string name, params Type[] types) |
|||
{ |
|||
Check.NotNull(list, nameof(list)); |
|||
Check.NotNull(name, nameof(name)); |
|||
Check.NotNull(types, nameof(types)); |
|||
|
|||
list.Add(new NamedTypeSelector(name, type => types.Any(type.IsAssignableFrom))); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
using System.Linq; |
|||
using Volo.Abp.Domain.Entities; |
|||
|
|||
namespace Volo.Abp.Auditing |
|||
{ |
|||
public static class EntityHistorySelectorListExtensions |
|||
{ |
|||
public const string AllEntitiesSelectorName = "Abp.Entities.All"; |
|||
|
|||
public static void AddAllEntities(this IEntityHistorySelectorList selectors) |
|||
{ |
|||
if (selectors.Any(s => s.Name == AllEntitiesSelectorName)) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
selectors.Add(new NamedTypeSelector(AllEntitiesSelectorName, t => typeof(IEntity).IsAssignableFrom(t))); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue