/
krasninja
/
querycat
Обзор
Документация
Войти
/
krasninja
/
querycat
Код
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/QueryCat.Cli/Commands/Options/ApplicationOptionsBinder.cs
40 строк
1 KB
Ivan Kozhin
Change logger to Microsoft.Extensions.Logging
24 апр 2023, 19:01
24 апр 2023, 19:01
b686186
Код
Авторство
О чём код?
using System.CommandLine; using System.CommandLine.Binding; using Microsoft.Extensions.Logging; namespace QueryCat.Cli.Commands.Options; /// <summary> /// Command line parameters binder for <see cref="ApplicationOptions" />. /// </summary> internal class ApplicationOptionsBinder : BinderBase<ApplicationOptions> { private readonly Option<LogLevel> _logLevelOption; #if ENABLE_PLUGINS private readonly Option<string[]> _pluginDirectoriesOption; #endif /// <inheritdoc /> public ApplicationOptionsBinder( Option<LogLevel> logLevelOption, Option<string[]> pluginDirectoriesOption) { _logLevelOption = logLevelOption; #if ENABLE_PLUGINS _pluginDirectoriesOption = pluginDirectoriesOption; #endif } /// <inheritdoc /> protected override ApplicationOptions GetBoundValue(BindingContext bindingContext) { return new ApplicationOptions { LogLevel = bindingContext.ParseResult.GetValueForOption(_logLevelOption), #if ENABLE_PLUGINS PluginDirectories = bindingContext.ParseResult.GetValueForOption(_pluginDirectoriesOption) ?? Array.Empty<string>(), #endif }; } }