/// <summary> /// Uses the redis. /// </summary> /// <param name="options">Options.</param> /// <param name="name"></param> /// <param name="setupActions"></param> public static BloomFilterOptions UseRedis(this BloomFilterOptions options, string name = BloomFilterConstValue.DefaultRedisName, Action <FilterRedisOptions> setupActions = null) { var filterRedisOptions = new FilterRedisOptions { Name = name }; setupActions?.Invoke(filterRedisOptions); options.RegisterExtension(new FilterRedisOptionsExtension(filterRedisOptions)); return(options); }
/// <summary> /// Adds the BloomFilter. /// </summary> /// <param name="services">Services.</param> /// <param name="setupAction">Setup action.</param> public static IServiceCollection AddBloomFilter(this IServiceCollection services, Action <BloomFilterOptions> setupAction) { if (setupAction == null) { throw new ArgumentNullException(nameof(setupAction)); } //Options and extension service var options = new BloomFilterOptions(); setupAction(options); foreach (var serviceExtension in options.Extensions) { serviceExtension.AddServices(services); } services.AddSingleton(options); return(services); }