// AddRedisOperationLogChangeTracking public static DbContextBuilder <TDbContext> AddRedisOperationLogChangeTracking <TDbContext>( this DbContextBuilder <TDbContext> dbContextBuilder, Action <IServiceProvider, RedisOperationLogChangeTrackingOptions <TDbContext> >?configureOptions = null) where TDbContext : DbContext { var services = dbContextBuilder.Services; services.TryAddSingleton(c => { var options = new RedisOperationLogChangeTrackingOptions <TDbContext>(); configureOptions?.Invoke(c, options); return(options); }); // RedisOperationLogChangeTracker<TDbContext> services.TryAddSingleton <RedisOperationLogChangeTracker <TDbContext> >(); services.AddHostedService(c => c.GetRequiredService <RedisOperationLogChangeTracker <TDbContext> >()); services.TryAddSingleton <IDbOperationLogChangeTracker <TDbContext> >(c => c.GetRequiredService <RedisOperationLogChangeTracker <TDbContext> >()); // RedisOperationLogChangeNotifier<TDbContext> services.TryAddEnumerable( ServiceDescriptor.Singleton < IOperationCompletionListener, RedisOperationLogChangeNotifier <TDbContext> >()); return(dbContextBuilder); }
public RedisOperationLogChangeNotifier( RedisOperationLogChangeTrackingOptions <TDbContext> options, AgentInfo agentInfo, IServiceProvider services) : base(services) { Options = options; AgentInfo = agentInfo; RedisDb = Services.GetService <RedisDb <TDbContext> >() ?? Services.GetRequiredService <RedisDb>(); RedisPub = RedisDb.GetPub(options.PubSubKey); Log.LogInformation("Using pub/sub key = '{Key}'", RedisPub.FullKey); }
public RedisOperationLogChangeTracker( RedisOperationLogChangeTrackingOptions <TDbContext> options, AgentInfo agentInfo, IServiceProvider services) : base(services) { Options = options; AgentInfo = agentInfo; RedisDb = Services.GetService <RedisDb <TDbContext> >() ?? Services.GetRequiredService <RedisDb>(); RedisSub = RedisDb.GetChannelSub(options.PubSubKey); Log.LogInformation("Using pub/sub key = '{Key}'", RedisSub.FullKey); // ReSharper disable once VirtualMemberCallInConstructor ReplaceNextEventTask(); }