using System.Text.RegularExpressions; namespace LTEMvcApp.Models { /// /// 日志模型配置 /// public static class LogModelConfig { /// /// 模型列表(顺序重要) /// public static readonly string[] ModelList = { "RUE", "UE", "PROBE", "ENB", "N3IWF", "MBMSGW", "MME", "IMS", "LICENSE", "MONITOR" }; /// /// 模型配置字典 /// public static readonly Dictionary 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" } }; /// /// 获取模型配置 /// /// 模型名称 /// 模型配置 public static ModelConfig? GetModelConfig(string modelName) { return Models.TryGetValue(modelName, out var config) ? config : null; } /// /// 根据提示匹配模型 /// /// 提示文本 /// 匹配的模型名称 public static string? MatchModelByHint(string hint) { foreach (var kvp in Models) { if (kvp.Value.ModelHint?.IsMatch(hint) == true) { return kvp.Key; } } return null; } /// /// 获取所有模型名称 /// /// 模型名称列表 public static List GetAllModelNames() { return ModelList.ToList(); } /// /// 验证模型名称是否有效 /// /// 模型名称 /// 是否有效 public static bool IsValidModel(string modelName) { return Models.ContainsKey(modelName); } } /// /// 模型配置 /// public class ModelConfig { /// /// 图标类名 /// public string? Icon { get; set; } /// /// 模型提示正则表达式 /// public Regex? ModelHint { get; set; } /// /// 显示标题 /// public string? Title { get; set; } } }