示例#1
0
        private static FieldInfo[] GetFieldInfos(Type type)
        {
            FieldInfo[]      fieldInfos = type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
            List <FieldInfo> list       = new List <FieldInfo>();

            foreach (var fieldInfo in fieldInfos)
            {
                if (fieldInfo.IsPublic)
                {
                    FieldHide fieldHide = fieldInfo.GetCustomAttribute <FieldHide>();
                    if (fieldHide == null)
                    {
                        list.Add(fieldInfo);
                    }
                }
                else
                {
                    FieldShow fieldShow = fieldInfo.GetCustomAttribute <FieldShow>();
                    if (fieldShow != null)
                    {
                        list.Add(fieldInfo);
                    }
                }
            }

            list.Sort((item1, item2) =>
            {
                var item1Attr = item1.GetCustomAttribute <FieldOrder>();
                var item2Attr = item2.GetCustomAttribute <FieldOrder>();
                int order1    = item1Attr != null ? item1Attr.Order : 9999;
                int order2    = item2Attr != null ? item2Attr.Order : 9999;
                return(order1.CompareTo(order2));
            });
            return(list.ToArray());
        }
示例#2
0
        public static void SetAndAddFieldShow_Fold(string fieldName, bool fold)
        {
            if (!fieldShows.ContainsKey(fieldName))
            {
                fieldShows.Add(fieldName, new FieldShow()
                {
                    Fold = false
                });
            }

            fieldShows[fieldName] = new FieldShow()
            {
                Fold = fold
            };
        }