Files
2025-09-16 16:06:41 +08:00

38 lines
1.3 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using Szmedi.RevitToolkit.Approval.Models;
namespace Szmedi.RevitToolkit.Approval.Assists
{
internal class IOAssists
{
public static string GetMvdLiteContent(string majorName)
{
var dir = Path.Combine(GlobalAssists.DirAssembly, "mvdlite");
var fileContent = Directory.GetFiles(dir, "*.mvdlite")
.FirstOrDefault(f => f.Contains(majorName)) switch
{
string file when !string.IsNullOrEmpty(file) => File.ReadAllText(file),
_ => throw new FileNotFoundException("未找到对应的MVDLite文件请检查目录或文件名。")
};
return fileContent;
}
public static string GetMvdLiteContent(Major major)
{
var fieldInfo = major.GetType().GetField(major.ToString());
DescriptionAttribute descriptionAttribute = fieldInfo.GetCustomAttribute<DescriptionAttribute>();
var majorName = descriptionAttribute.Description;
return GetMvdLiteContent(majorName);
}
}
}