From fb228b5d1b94e143d3e36c5df56a3d8311ecec2b Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Tue, 9 Feb 2021 21:41:08 -0600 Subject: update docs --- .../Configuration/YamlConfigurationSource.cs | 86 ++++++++++++++-------- 1 file changed, 54 insertions(+), 32 deletions(-) (limited to 'src/slskd/Common/Configuration/YamlConfigurationSource.cs') diff --git a/src/slskd/Common/Configuration/YamlConfigurationSource.cs b/src/slskd/Common/Configuration/YamlConfigurationSource.cs index 27ca6fea..7766e14c 100644 --- a/src/slskd/Common/Configuration/YamlConfigurationSource.cs +++ b/src/slskd/Common/Configuration/YamlConfigurationSource.cs @@ -1,10 +1,28 @@ -namespace slskd.Configuration +// +// Copyright (c) slskd Team. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published +// by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see https://www.gnu.org/licenses/. +// + +#pragma warning disable SA1649 // File name should match first type name +namespace slskd.Configuration { - using Microsoft.Extensions.Configuration; - using Microsoft.Extensions.FileProviders; using System; using System.IO; using System.Linq; + using Microsoft.Extensions.Configuration; + using Microsoft.Extensions.FileProviders; using YamlDotNet.Core; using YamlDotNet.RepresentationModel; @@ -17,11 +35,14 @@ /// Adds a YAML configuration source to . /// /// The to add to. - /// Path relative to the base path stored in - /// of . + /// + /// Path relative to the base path stored in of . + /// /// Whether the file is optional. /// Whether the configuration should be reloaded if the file changes. - /// A value indicating whether configuration keys should be normalized (_, - removed, changed to lowercase). + /// + /// A value indicating whether configuration keys should be normalized (_, - removed, changed to lowercase). + /// /// The to use to access the file. /// The . public static IConfigurationBuilder AddYamlFile(this IConfigurationBuilder builder, string path, bool optional = true, bool reloadOnChange = false, bool normalizeKeys = true, IFileProvider provider = null) @@ -57,45 +78,23 @@ => builder.Add(configureSource); } - /// - /// Represents a YAML file as an . - /// - public class YamlConfigurationSource : FileConfigurationSource - { - /// - /// Builds the for this source. - /// - /// The . - /// A - public override IConfigurationProvider Build(IConfigurationBuilder builder) - { - EnsureDefaults(builder); - return new YamlConfigurationProvider(this); - } - - /// - /// Gets or sets a value indicating whether configuration keys should be normalized (_, - removed, changed to lowercase). - /// - public bool NormalizeKeys { get; set; } - } - /// /// A YAML file based . /// public class YamlConfigurationProvider : FileConfigurationProvider { /// - /// Initializes a new instance with the specified source. + /// Initializes a new instance of the class. /// /// The source settings. - public YamlConfigurationProvider(YamlConfigurationSource source) - : base(source) + public YamlConfigurationProvider(YamlConfigurationSource source) + : base(source) { NormalizeKeys = source.NormalizeKeys; } private bool NormalizeKeys { get; set; } - private string[] NullValues { get; } = new[] { "~", "null", "" }; + private string[] NullValues { get; } = new[] { "~", "null", string.Empty }; /// /// Loads the YAML data from a stream. @@ -157,4 +156,27 @@ } } } + + /// + /// Represents a YAML file as an . + /// + public class YamlConfigurationSource : FileConfigurationSource + { + /// + /// Gets or sets a value indicating whether configuration keys should be normalized (_, - removed, changed to lowercase). + /// + public bool NormalizeKeys { get; set; } + + /// + /// Builds the for this source. + /// + /// The . + /// A . + public override IConfigurationProvider Build(IConfigurationBuilder builder) + { + EnsureDefaults(builder); + return new YamlConfigurationProvider(this); + } + } } +#pragma warning restore SA1649 // File name should match first type name \ No newline at end of file -- cgit v1.2.3