Beispiel #1
0
        public static IrpClassInfo GetTypeInfo(Type type, Func <Type, PredicateInfo> TypePredicate, Func <FieldInfo, bool> filePredicate, bool ignorePredicate = false)
        {
            var predicate = TypePredicate(type);

            if ((ignorePredicate || predicate.IsProxy) && predicate.IsBaseType == true && type.FullName.Contains("+") == false)
            {
                IrpClassInfo classItem = new IrpClassInfo();
                classItem.Fields      = new List <IrpFieldInfo>();
                classItem.ClassName   = type.FullName;
                classItem.DisplayName = predicate.DisplayName;
                classItem.IsSubClass  = predicate.IsSubClass;
                classItem.IsObject    = predicate.IsObject;
                var fieldList = type.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
                foreach (var field in fieldList)
                {
                    if (filePredicate(field) == true)
                    {
                        var fieldInfo = new IrpFieldInfo();
                        fieldInfo.FieldName = field.Name;
                        fieldInfo.FieldType = field.FieldType.ToString();
                        fieldInfo.ClassInfo = GetTypeInfo(field.FieldType, TypePredicate, filePredicate, true);
                        classItem.Fields.Add(fieldInfo);
                    }
                }

                return(classItem);
            }

            return(null);
        }
Beispiel #2
0
        public static List <string> GetFieldClasses(IrpClassInfo classInfo)
        {
            var classList = new List <string>();

            foreach (var field in classInfo.Fields)
            {
                if (field.ClassInfo != null)
                {
                    classList.Add(field.FieldType);
                    classList = classList.Union(GetFieldClasses(field.ClassInfo)).ToList();
                }
            }
            return(classList);
        }