123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- using FWindSoft.SystemExtensions;
- using System;
- using System.Linq;
- using System.Reflection;
- namespace FWindSoft.Revit.ExtensibleStorage
- {
- /// <summary>
- /// 内部应用
- /// </summary>
- internal class InEnumUtil
- {
- /// <summary>
- /// 获取枚举的guid
- /// </summary>
- /// <param name="en"></param>
- /// <returns></returns>
- public static Guid GetGuid(Enum en)
- {
- var type = en.GetType();
- string allPath = type.FullName + en.ToString();
- return allPath.ToGuid();
- }
- internal static SchemaItem CreateSchemaItem(Enum en)
- {
- SchemaItem item = new SchemaItem();
- FieldInfo fieldInfo = en.GetType().GetField(en.ToString());
- var fileNameAttribute = fieldInfo.GetCustomAttribute<StorageFileNameAttribute>();
- item.FileName = fileNameAttribute?.Name?? en.ToString();
- var schemeNameAttribute = fieldInfo.GetCustomAttribute<StorageSchemeNameAttribute>();
- item.SchemaName = schemeNameAttribute?.Name ?? en.ToString();
- var schemeGuidAttribute = fieldInfo.GetCustomAttribute<StorageSchemeGuidAttribute>();
- if (schemeGuidAttribute?.Guid == null)
- {
- item.SchemaGuid = GetGuid(en);
- }
- else
- {
- item.SchemaGuid = new Guid(schemeGuidAttribute?.Guid);
- }
- return item;
- }
- }
- }
|