using Microsoft.Extensions.DependencyInjection; namespace zero.Api; public static class ServiceCollectionExtensions { public static ZeroBuilder AddApi(this ZeroBuilder builder) where T : ZeroApiPlugin, IZeroPlugin, new() { return builder.AddApi(_ => { }); } public static ZeroBuilder AddApi(this ZeroBuilder builder) { return builder.AddApi(); } public static ZeroBuilder AddApi(this ZeroBuilder builder, Action options) where T : ZeroApiPlugin, IZeroPlugin, new() { return builder.AddPlugin(services => { T plugin = new(); plugin.PostConfigureServices = (services, configuration) => { services.Configure(opts => options(opts)); }; return plugin; }); } }