public static HandlerRegistrar AddEntityHandlers(this HandlerRegistrar registrar) { return(registrar .Add(typeof(Add <>)) .Add(typeof(Delete <>)) .Add(typeof(Find <>)) .Add(typeof(GetAll <>))); }
// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { services.AddRazorPages(); services.AddServerSideBlazor(); services.AddSingleton <WeatherForecastService>(); //MVU# Setup services.AddScoped(typeof(MvuProgram <, , ,>)); //Services services.AddSingleton(new RandomGenerator()); //Handlers var handlers = new HandlerRegistrar(); handlers.Add(async(Request.RandomInt _, RandomGenerator generator, CancellationToken cancellationToken) => { var random = generator.RandomInt(0, 100); await Task.Delay(random * 20, cancellationToken); return(random); }); services.AddSingleton(handlers); }