添加项目文件。
This commit is contained in:
37
Szmedi.RevitToolkit.Approval/Assists/IOAssists.cs
Normal file
37
Szmedi.RevitToolkit.Approval/Assists/IOAssists.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user