public static IDryvMvcBuilder AddDryvPreloading(this IDryvMvcBuilder dryvBuilder, Action <DryvPreloaderOptions> setupAction = null) { var options = new DryvPreloaderOptions { IsEnabled = true }; setupAction?.Invoke(options); dryvBuilder.Services.AddSingleton(Options.Create(options)); dryvBuilder.Services.AddSingleton <DryvPreloader>(); dryvBuilder.Services.AddSingleton(new DryvMvcInitializer(services => services.GetService <DryvPreloader>().Preload())); return(dryvBuilder); }
public static IDryvMvcBuilder AddDryvDynamicControllers(this IDryvMvcBuilder dryvBuilder, Action <DryvDynamicControllerOptions> setupAction = null) { var services = dryvBuilder.Services; var options = new DryvDynamicControllerOptions(); setupAction?.Invoke(options); services.AddSingleton(Options.Create(options)); services.AddSingleton <ControllerGenerator>(); services.AddSingleton <DryvDynamicControllerRegistration>(); services.AddSingleton <ICustomTranslator, DryvDynamicControllerTranslator>(); services.TryAddSingleton <IActionContextAccessor, ActionContextAccessor>(); services.TryAddSingleton(typeof(IDryvClientServerCallWriter), options.DynamicControllerCallWriterType ?? typeof(DryvClientServerCallWriter)); var actionDescriptorChangeProvider = new DryvDynamicActionDescriptorChangeProvider(); services.AddSingleton <IActionDescriptorChangeProvider>(actionDescriptorChangeProvider); services.AddSingleton(actionDescriptorChangeProvider); SetupEndpointMapping(services); return(dryvBuilder); }