コード例 #1
0
 public static IServiceCollection AddStateReducer <TSubject>(this IServiceCollection services, Action <IStateReducerBuilder <TSubject>, IServiceProvider> configuration)
     where TSubject : class, IStateSubject <TSubject>
 {
     return(services
            .AddTransient <IStateReducer <TSubject>, StateReducer <TSubject> >()
            .AddSingleton(provider =>
     {
         var builder = new StateReducerBuilder <TSubject>();
         configuration?.Invoke(builder, provider);
         return builder.Build(provider);
     }));
 }
コード例 #2
0
        public IStateReducerFactoryBuilder <TKey, TSubject> AddStateReducer(TKey key, Action <IStateReducerBuilder <TSubject> > configuration)
        {
            this.Remove(key);
            this.stateReducers.Add(key, provider =>
            {
                var builder = new StateReducerBuilder <TSubject>();
                configuration.Invoke(builder);

                return(builder.Build(provider));
            });

            return(this);
        }