Exemple #1
0
        /// <summary> </summary>
        /// <param name="clazz">The class to instrospect
        /// </param>
        /// <param name="recursive">If true, goes does the hierarchy to try to analyse all classes
        /// </param>
        /// <param name="A">map with classname that are being introspected, to avoid recursive calls
        ///
        /// </param>
        /// <returns>
        /// </returns>
        private ClassInfoList InternalIntrospect(System.Type clazz, bool recursive, ClassInfoList classInfoList)
        {
            if (classInfoList != null)
            {
                ClassInfo existingCi = (ClassInfo)classInfoList.GetClassInfoWithName(OdbClassUtil.GetFullName(clazz));
                if (existingCi != null)
                {
                    return(classInfoList);
                }
            }

            ClassInfo classInfo = new ClassInfo(OdbClassUtil.GetFullName(clazz));

            classInfo.SetClassCategory(GetClassCategory(OdbClassUtil.GetFullName(clazz)));
            if (classInfoList == null)
            {
                classInfoList = new ClassInfoList(classInfo);
            }
            else
            {
                classInfoList.AddClassInfo(classInfo);
            }

            // Field[] fields = clazz.getDeclaredFields();
            //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Class.getName' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
            //m by cristi
            IOdbList <FieldInfo>          fields     = GetAllFields(OdbClassUtil.GetFullName(clazz));
            IOdbList <ClassAttributeInfo> attributes = new OdbArrayList <ClassAttributeInfo>(fields.Count);

            ClassInfo ci = null;

            for (int i = 0; i < fields.Count; i++)
            {
                System.Reflection.FieldInfo field = (System.Reflection.FieldInfo)fields[i];
                //Console.WriteLine("Field " + field.Name + " , type = " + field.FieldType);
                if (!ODBType.GetFromClass(field.FieldType).IsNative())
                {
                    if (recursive)
                    {
                        classInfoList = InternalIntrospect(field.FieldType, recursive, classInfoList);
                        ci            = classInfoList.GetClassInfoWithName(OdbClassUtil.GetFullName(field.FieldType));
                    }
                    else
                    {
                        ci = new ClassInfo(OdbClassUtil.GetFullName(field.FieldType));
                    }
                }
                else
                {
                    ci = null;
                }
                attributes.Add(new ClassAttributeInfo((i + 1), field.Name, field.FieldType, OdbClassUtil.GetFullName(field.FieldType), ci));
            }
            classInfo.SetAttributes(attributes);
            classInfo.SetMaxAttributeId(fields.Count);
            return(classInfoList);
        }