ConfigurationPath
Utility methods and constants for manipulating Configuration paths.
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
namespace Microsoft.Extensions.Configuration
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
public static class ConfigurationPath
{
public static readonly string KeyDelimiter = ":";
public static string Combine(params string[] pathSegments)
{
System.ThrowHelper.ThrowIfNull(pathSegments, "pathSegments");
return string.Join(KeyDelimiter, pathSegments);
}
public static string Combine(IEnumerable<string> pathSegments)
{
System.ThrowHelper.ThrowIfNull(pathSegments, "pathSegments");
return string.Join(KeyDelimiter, pathSegments);
}
[System.Runtime.CompilerServices.NullableContext(2)]
[return: System.Diagnostics.CodeAnalysis.NotNullIfNotNull("path")]
public static string GetSectionKey(string path)
{
if (string.IsNullOrEmpty(path))
return path;
int num = path.LastIndexOf(':');
if (num >= 0)
return path.Substring(num + 1);
return path;
}
[System.Runtime.CompilerServices.NullableContext(2)]
public static string GetParentPath(string path)
{
if (string.IsNullOrEmpty(path))
return null;
int num = path.LastIndexOf(':');
if (num >= 0)
return path.Substring(0, num);
return null;
}
}
}