aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Common/Configuration/YamlConfigurationSource.cs
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2021-02-09 21:41:08 -0600
committerJP Dillingham <jpdillingham@gmail.com>2021-02-09 21:41:08 -0600
commitfb228b5d1b94e143d3e36c5df56a3d8311ecec2b (patch)
tree13dc3559cf121d9122b0978024746bcb199747f5 /src/slskd/Common/Configuration/YamlConfigurationSource.cs
parent0ae935536fd8fa8862df7c936dfad59de8e55753 (diff)
downloadslskd-fb228b5d1b94e143d3e36c5df56a3d8311ecec2b.tar.gz
update docs
Diffstat (limited to 'src/slskd/Common/Configuration/YamlConfigurationSource.cs')
-rw-r--r--src/slskd/Common/Configuration/YamlConfigurationSource.cs86
1 files changed, 54 insertions, 32 deletions
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 file="YamlConfigurationSource.cs" company="slskd Team">
+// 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/.
+// </copyright>
+
+#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 <paramref name="builder"/>.
/// </summary>
/// <param name="builder">The <see cref="IConfigurationBuilder"/> to add to.</param>
- /// <param name="path">Path relative to the base path stored in
- /// <see cref="IConfigurationBuilder.Properties"/> of <paramref name="builder"/>.</param>
+ /// <param name="path">
+ /// Path relative to the base path stored in <see cref="IConfigurationBuilder.Properties"/> of <paramref name="builder"/>.
+ /// </param>
/// <param name="optional">Whether the file is optional.</param>
/// <param name="reloadOnChange">Whether the configuration should be reloaded if the file changes.</param>
- /// <param name="normalizeKeys">A value indicating whether configuration keys should be normalized (_, - removed, changed to lowercase).</param>
+ /// <param name="normalizeKeys">
+ /// A value indicating whether configuration keys should be normalized (_, - removed, changed to lowercase).
+ /// </param>
/// <param name="provider">The <see cref="IFileProvider"/> to use to access the file.</param>
/// <returns>The <see cref="IConfigurationBuilder"/>.</returns>
public static IConfigurationBuilder AddYamlFile(this IConfigurationBuilder builder, string path, bool optional = true, bool reloadOnChange = false, bool normalizeKeys = true, IFileProvider provider = null)
@@ -58,44 +79,22 @@
}
/// <summary>
- /// Represents a YAML file as an <see cref="IConfigurationSource"/>.
- /// </summary>
- public class YamlConfigurationSource : FileConfigurationSource
- {
- /// <summary>
- /// Builds the <see cref="YamlConfigurationProvider"/> for this source.
- /// </summary>
- /// <param name="builder">The <see cref="IConfigurationBuilder"/>.</param>
- /// <returns>A <see cref="YamlConfigurationProvider"/></returns>
- public override IConfigurationProvider Build(IConfigurationBuilder builder)
- {
- EnsureDefaults(builder);
- return new YamlConfigurationProvider(this);
- }
-
- /// <summary>
- /// Gets or sets a value indicating whether configuration keys should be normalized (_, - removed, changed to lowercase).
- /// </summary>
- public bool NormalizeKeys { get; set; }
- }
-
- /// <summary>
/// A YAML file based <see cref="FileConfigurationProvider"/>.
/// </summary>
public class YamlConfigurationProvider : FileConfigurationProvider
{
/// <summary>
- /// Initializes a new instance with the specified source.
+ /// Initializes a new instance of the <see cref="YamlConfigurationProvider"/> class.
/// </summary>
/// <param name="source">The source settings.</param>
- 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 };
/// <summary>
/// Loads the YAML data from a stream.
@@ -157,4 +156,27 @@
}
}
}
+
+ /// <summary>
+ /// Represents a YAML file as an <see cref="IConfigurationSource"/>.
+ /// </summary>
+ public class YamlConfigurationSource : FileConfigurationSource
+ {
+ /// <summary>
+ /// Gets or sets a value indicating whether configuration keys should be normalized (_, - removed, changed to lowercase).
+ /// </summary>
+ public bool NormalizeKeys { get; set; }
+
+ /// <summary>
+ /// Builds the <see cref="YamlConfigurationProvider"/> for this source.
+ /// </summary>
+ /// <param name="builder">The <see cref="IConfigurationBuilder"/>.</param>
+ /// <returns>A <see cref="YamlConfigurationProvider"/>.</returns>
+ 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