mh_frame_sps/APT.Infrastructure.Core/Utils/InitUtils.cs

56 lines
1.6 KiB
C#
Raw Normal View History

2026-04-07 13:47:52 +08:00
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Reflection;
using System.Xml;
namespace APT.Infrastructure.Core.Utils
{
public class InitUtils
{
public static void Init()
{
DoInitMessageFormat();
}
/// <summary>
/// 初始化错误消息
/// </summary>
private static void DoInitMessageFormat()
{
var files = System.IO.Directory.GetFiles(System.AppContext.BaseDirectory, "Message*.xml");
foreach (var file in files)
{
XmlDocument xx = new XmlDocument();
xx.Load(file);
var x1 = xx.DocumentElement;
var xs = x1.GetElementsByTagName("message");
foreach (var x in xs)
{
var node = (XmlElement)x;
var name = node.GetAttribute("name");
if (string.IsNullOrEmpty(name)) continue;
LibMessageFormat access = new LibMessageFormat
{
Code = name
};
var fields = node.GetElementsByTagName("item");
foreach (var f in fields)
{
var fieldNode = (XmlElement)f;
var lang = fieldNode.GetAttribute("lang");
access.AddFormat(lang, fieldNode.InnerText);
}
LibMessageFormatManager.Instance.AddMessageFormat(access);
}
}
}
}
}