Ejemplo n.º 1
0
        internal void BuildFieldList(StorageImpl storage, Type cls, List<FieldDescriptor> list)
        {
            Type superclass = cls.BaseType;
            if (superclass != null)
            {
                BuildFieldList(storage, superclass, list);
            }

            FieldInfo[] flds = cls.GetFields(
                BindingFlags.Instance | BindingFlags.NonPublic |
                BindingFlags.Public | BindingFlags.DeclaredOnly |
                BindingFlags.Static);

            foreach (FieldInfo f in flds)
            {
                //UPGRADE_ISSUE: Method 'java.lang.reflect.Field.getModifiers' was not converted.
                //UPGRADE_ISSUE: Field 'java.lang.reflect.Modifier.TRANSIENT' was not converted.
                //UPGRADE_ISSUE: Field 'java.lang.reflect.Modifier.STATIC' was not converted.
                //if ((f.getModifiers() & (Modifier.TRANSIENT | Modifier.STATIC)) == 0)
                if (f.IsStatic || f.IsNotSerialized)
                    continue;

                //UPGRADE_ISSUE: Method 'java.lang.reflect.AccessibleObject.setAccessible' was not converted.
                //f.setAccessible(true);
                FieldDescriptor fd = new FieldDescriptor();
                fd.field = f;
                fd.fieldName = f.Name;
                //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Class.getName' may return a different value.
                fd.className = cls.FullName;
                int type = GetTypeCode(f.FieldType);
                switch (type)
                {
                    case tpObject:
                    case tpLink:
                    case tpArrayOfObject:
                        hasReferences = true;
                        break;

                    case tpValue:
                        fd.valueDesc = storage.GetClassDescriptor(f.FieldType);
                        hasReferences |= fd.valueDesc.hasReferences;
                        break;

                    case tpArrayOfValue:
                        fd.valueDesc = storage.GetClassDescriptor(f.FieldType.GetElementType());
                        hasReferences |= fd.valueDesc.hasReferences;
                        break;
                }
                fd.type = type;
                list.Add(fd);
            }
        }