You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

121 lines
3.5 KiB

using System.Text.RegularExpressions;
namespace LTEMvcApp.Models
{
/// <summary>
/// 日志模型配置
/// </summary>
public static class LogModelConfig
{
/// <summary>
/// 模型列表(顺序重要)
/// </summary>
public static readonly string[] ModelList =
{
"RUE", "UE", "PROBE", "ENB", "N3IWF", "MBMSGW", "MME", "IMS", "LICENSE", "MONITOR"
};
/// <summary>
/// 模型配置字典
/// </summary>
public static readonly Dictionary<string, ModelConfig> Models = new()
{
["RUE"] = new() { Icon = "icon-ue2" },
["UE"] = new() { Icon = "icon-ue" },
["PROBE"] = new() { },
["ENB"] = new()
{
Icon = "icon-air",
ModelHint = new Regex(@"enb|gnb|bbu", RegexOptions.IgnoreCase),
Title = "RAN"
},
["N3IWF"] = new()
{
Icon = "icon-air",
ModelHint = new Regex(@"n3iwf", RegexOptions.IgnoreCase),
Title = "N3IWF"
},
["MME"] = new()
{
Icon = "icon-server",
ModelHint = new Regex(@"epc|mme|amf", RegexOptions.IgnoreCase),
Title = "CN"
},
["MBMSGW"] = new()
{
Icon = "icon-download",
ModelHint = new Regex(@"mbms", RegexOptions.IgnoreCase)
},
["IMS"] = new() { Icon = "icon-dial" },
["MONITOR"] = new() { Icon = "icon-monitor" },
["LICENSE"] = new() { Icon = "icon-file" }
};
/// <summary>
/// 获取模型配置
/// </summary>
/// <param name="modelName">模型名称</param>
/// <returns>模型配置</returns>
public static ModelConfig? GetModelConfig(string modelName)
{
return Models.TryGetValue(modelName, out var config) ? config : null;
}
/// <summary>
/// 根据提示匹配模型
/// </summary>
/// <param name="hint">提示文本</param>
/// <returns>匹配的模型名称</returns>
public static string? MatchModelByHint(string hint)
{
foreach (var kvp in Models)
{
if (kvp.Value.ModelHint?.IsMatch(hint) == true)
{
return kvp.Key;
}
}
return null;
}
/// <summary>
/// 获取所有模型名称
/// </summary>
/// <returns>模型名称列表</returns>
public static List<string> GetAllModelNames()
{
return ModelList.ToList();
}
/// <summary>
/// 验证模型名称是否有效
/// </summary>
/// <param name="modelName">模型名称</param>
/// <returns>是否有效</returns>
public static bool IsValidModel(string modelName)
{
return Models.ContainsKey(modelName);
}
}
/// <summary>
/// 模型配置
/// </summary>
public class ModelConfig
{
/// <summary>
/// 图标类名
/// </summary>
public string? Icon { get; set; }
/// <summary>
/// 模型提示正则表达式
/// </summary>
public Regex? ModelHint { get; set; }
/// <summary>
/// 显示标题
/// </summary>
public string? Title { get; set; }
}
}