zhangyuekai
2024-08-09 68517aa090c54df2e0999bd60af808419ca25cf7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using HStation.RevitDev.Model.AttributeClass;
using HStation.RevitDev.Model.ModelEnum;
using HStation.RevitDev.RevitDataExport.Common;
 
namespace HStation.RevitDev.RevitDataExport.Utility
{
    public static class RevitTypeExtense
    {
        public static bool IsRequired(this RevitType type)
        {
            var config = GlobalResource.ConfigModel;
            var props = config.GetType().GetProperties();
 
            foreach (var prop in props) 
            {
                var attrs = prop.GetCustomAttributes(false);
                if (attrs.Length > 0)
                {
                    var attr = attrs[0] as RevitTypeAttribute;
                    if (attr.m_revitType == type)
                    {
                        bool? isRequired = prop.GetValue(config) as bool?;
                        if (isRequired == true)
                        {
                            return true;
                        }
                        return false;
                    }
                }
            }
 
            return false;
        }
    }
}