// SPDX-License-Identifier: AGPL-3.0-only
/**
* Digital Voice Modem - Desktop Dispatch Console
* AGPLv3 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Desktop Dispatch Console
* @license AGPLv3 License (https://opensource.org/licenses/AGPL-3.0)
*
* Copyright (C) 2025 Caleb, K4PHP
*
*/
using System.IO;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;
namespace dvmconsole
{
///
///
///
public class RadioAlias
{
///
///
///
public string Alias { get; set; }
///
///
///
public int Rid { get; set; }
} //public class RadioAlias
///
///
///
public static class AliasTools
{
/*
** Methods
*/
///
///
///
///
///
///
public static List LoadAliases(string filePath)
{
if (!File.Exists(filePath))
throw new FileNotFoundException("Alias file not found.", filePath);
var deserializer = new DeserializerBuilder()
.WithNamingConvention(CamelCaseNamingConvention.Instance)
.Build();
var yamlText = File.ReadAllText(filePath);
return deserializer.Deserialize>(yamlText);
}
///
///
///
///
///
///
public static string GetAliasByRid(List aliases, int rid)
{
if (aliases == null || aliases.Count == 0)
return string.Empty;
var match = aliases.FirstOrDefault(a => a.Rid == rid);
return match?.Alias ?? string.Empty;
}
} //public static class AliasTools
} // namespace DVMConsole