mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
* #10997 - Added JSON schema and extra shell class * #13510 - Address feedback and fix wrong typo for a member * #13510 - Add DevDoc (first version) * #13510 - make spellcheck happy * #13510 Address feedback, add scores, replace todos * Make build server happy * #13510 - Address feedback - Extra table for keys * #13510 - Address feedback * #13510 -Address feedback, add language specified Co-authored-by: Sekan, Tobias <tobias.sekan@axp-consulting.de>
68 lines
3.2 KiB
C#
68 lines
3.2 KiB
C#
// Copyright (c) Microsoft Corporation
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Wox.Plugin.Logger;
|
|
|
|
namespace Microsoft.PowerToys.Run.Plugin.WindowsSettings.Helper
|
|
{
|
|
/// <summary>
|
|
/// Helper class to help with the path of a <see cref="WindowsSetting"/>. The settings path shows where to find a setting within Windows' user interface.
|
|
/// </summary>
|
|
internal static class WindowsSettingsPathHelper
|
|
{
|
|
/// <summary>
|
|
/// The symbol which is used as delimiter between the parts of the path.
|
|
/// </summary>
|
|
private const string _pathDelimiterSequence = "\u0020\u0020\u02C3\u0020\u0020"; // = "<space><space><arrow><space><space>"
|
|
|
|
/// <summary>
|
|
/// Generates the values for <see cref="WindowsSetting.JoinedAreaPath"/> and <see cref="WindowsSetting.JoinedFullSettingsPath"/> on all settings of the list in the given <see cref="WindowsSettings"/> class.
|
|
/// </summary>
|
|
/// <param name="windowsSettings">A class that contain all possible windows settings.</param>
|
|
internal static void GenerateSettingsPathValues(in WindowsSettings windowsSettings)
|
|
{
|
|
if (windowsSettings?.Settings is null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
foreach (var settings in windowsSettings.Settings)
|
|
{
|
|
// Check if type value is filled. If not, then write log warning.
|
|
if (string.IsNullOrEmpty(settings.Type))
|
|
{
|
|
Log.Warn($"The type property is not set for setting [{settings.Name}] in json. Skipping generating of settings path.", typeof(WindowsSettingsPathHelper));
|
|
continue;
|
|
}
|
|
|
|
// Check if "JoinedAreaPath" and "JoinedFullSettingsPath" are filled. Then log debug message.
|
|
if (!string.IsNullOrEmpty(settings.JoinedAreaPath))
|
|
{
|
|
Log.Debug($"The property [JoinedAreaPath] of setting [{settings.Name}] was filled from the json. This value is not used and will be overwritten.", typeof(WindowsSettingsPathHelper));
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(settings.JoinedFullSettingsPath))
|
|
{
|
|
Log.Debug($"The property [JoinedFullSettingsPath] of setting [{settings.Name}] was filled from the json. This value is not used and will be overwritten.", typeof(WindowsSettingsPathHelper));
|
|
}
|
|
|
|
// Generating path values.
|
|
if (!(settings.Areas is null) && settings.Areas.Any())
|
|
{
|
|
var areaValue = string.Join(_pathDelimiterSequence, settings.Areas);
|
|
settings.JoinedAreaPath = areaValue;
|
|
settings.JoinedFullSettingsPath = $"{settings.Type}{_pathDelimiterSequence}{areaValue}";
|
|
}
|
|
else
|
|
{
|
|
settings.JoinedAreaPath = string.Empty;
|
|
settings.JoinedFullSettingsPath = settings.Type;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|