namespace zero.Communication; public abstract partial class CollectionInterceptor : ICollectionInterceptor where T : ZeroIdEntity { /// public virtual bool CanRun(InterceptorParameters args, T model) => true; /// public virtual Task> Creating(InterceptorParameters args, T model) => Task.FromResult>(default); /// public virtual Task> Updating(InterceptorParameters args, T model) => Task.FromResult>(default); /// public virtual Task> Saving(InterceptorParameters args, T model) => Task.FromResult>(default); /// public virtual Task> Deleting(InterceptorParameters args, T model) => Task.FromResult>(default); /// public virtual Task Created(InterceptorParameters args, T model) => Task.CompletedTask; /// public virtual Task Updated(InterceptorParameters args, T model) => Task.CompletedTask; /// public virtual Task Saved(InterceptorParameters args, T model) => Task.CompletedTask; /// public virtual Task Deleted(InterceptorParameters args, T model) => Task.CompletedTask; } public abstract partial class CollectionInterceptor : CollectionInterceptor, ICollectionInterceptor { /// public override bool CanRun(InterceptorParameters args, ZeroIdEntity model) => base.CanRun(args, model); } public interface ICollectionInterceptor : ICollectionInterceptor { } public interface ICollectionInterceptor where T : ZeroIdEntity { /// /// Whether any of the interceptor methods is allowed to run based on the parameters /// bool CanRun(InterceptorParameters args, T model); /// /// Called after an entity has been stored but before the session has saved its changes /// Task Created(InterceptorParameters args, T model); /// /// Called before an entity is stored and validated /// Task> Creating(InterceptorParameters args, T model); /// /// Called after an entity has been deleted but before the session has saved its changes /// Task Deleted(InterceptorParameters args, T model); /// /// Called before an entity is deleted /// Task> Deleting(InterceptorParameters args, T model); /// /// Called after an entity has been updated but before the session has saved its changes /// Task Updated(InterceptorParameters args, T model); /// /// Called before an entity is stored and validated /// Task> Updating(InterceptorParameters args, T model); /// /// Called after an entity has been saved (created or updated) but before the session has saved its changes /// Task Saved(InterceptorParameters args, T model); /// /// Called before an entity is stored and validated /// Task> Saving(InterceptorParameters args, T model); }