/// <summary> /// Configures and registers QkRest dependencies. /// </summary> public static void AddQkRest(this IServiceCollection services, Action <QkOptions> configurationAction = null) { if (!qkRestAdded) { var options = new QkOptions(services); configurationAction?.Invoke(options); if (!options.exceptionsConfigured) { services.AddScoped <IQkExceptionHandler, QkExceptionHandler>(); } if (options.authorizationConfigured) { services.AddSingleton(typeof(IConfigureOptions <MvcOptions>), new QkMvcConfigureOptions(options)); } if (!options.disableSwagger) { services.AddSwaggerGen(); options.swaggerSetup.ForEach(services.ConfigureSwaggerGen); } qkRestAdded = true; return; } throw new InvalidOperationException(nameof(AddQkRest) + " should be called only once!"); }
public QkMvcConfigureOptions(QkOptions qkOptions) { this.qkOptions = qkOptions; }