using Microsoft.Extensions.Logging; namespace zero.Communication; public class Interceptors : IInterceptors { protected IZeroContext Context { get; set; } protected Lazy> Registrations { get; set; } protected ILogger Logger { get; set; } public Interceptors(IZeroContext context, Lazy> registrations, ILogger logger) { Context = context; Registrations = registrations; Logger = logger; } /// public InterceptorInstruction ForCreate(T model) where T : ZeroIdEntity, new() => new(this, Context, Registrations, Logger, InterceptorRunType.Create, model); /// public InterceptorInstruction ForUpdate(T model) where T : ZeroIdEntity, new() => new(this, Context, Registrations, Logger, InterceptorRunType.Update, model); /// public InterceptorInstruction ForDelete(T model) where T : ZeroIdEntity, new() => new(this, Context, Registrations, Logger, InterceptorRunType.Delete, model); } public interface IInterceptors { /// /// Instruction which can run interceptors before and after a creating an entity /// InterceptorInstruction ForCreate(T model) where T : ZeroIdEntity, new(); /// /// Instruction which can run interceptors before and after updating an entity /// InterceptorInstruction ForUpdate(T model) where T : ZeroIdEntity, new(); /// /// Instruction which can run interceptors before and after deleting an entity /// InterceptorInstruction ForDelete(T model) where T : ZeroIdEntity, new(); }