private static GenericsInfo CreateGenericsInfo(Type type) { var info = new GenericsInfo(); if (NullableReflection.TreatAsSystemNullableT(type)) { info.GenericArgumentCount = -1; } else if (GenericInstanceFactory.IsGenericInstanceType(type)) { info.GenericArgumentCount = -1; } else { var annotation = type.GetAnnotation <ITypeReflectionInfo>(typeof(ITypeReflectionInfo)); var args = annotation != null?annotation.GenericArgumentCount() : 0; if (args > 0) { var fieldNames = annotation.GenericArgumentsFields(); if (fieldNames.Length > 0) { var fields = type.JavaGetDeclaredFields(); info.GenericInstanceFields = fieldNames.Select(name => { var field = fields.FirstOrDefault(f => f.Name == name); field.IsAccessible = true; return(field); }); info.GenericInstanceFieldIsTypeArray = info.GenericInstanceFields.Length == 1 && info.GenericInstanceFields[0].Type == typeof(Type[]); } } info.GenericArgumentCount = args == 0 ? -1 : args; } return(info); }
private static GenericsInfo CreateGenericsInfo(Type type) { var info = new GenericsInfo(); if (NullableReflection.TreatAsSystemNullableT(type)) info.GenericArgumentCount = -1; else if (GenericInstanceFactory.IsGenericInstanceType(type)) info.GenericArgumentCount = -1; else { var annotation = type.GetAnnotation<ITypeReflectionInfo>(typeof(ITypeReflectionInfo)); var args = annotation != null ? annotation.GenericArgumentCount() : 0; if (args > 0) { var fieldNames = annotation.GenericArgumentsFields(); if (fieldNames.Length > 0) { var fields = type.JavaGetDeclaredFields(); info.GenericInstanceFields = fieldNames.Select(name => { var field = fields.FirstOrDefault(f => f.Name == name); field.IsAccessible = true; return field; }); info.GenericInstanceFieldIsTypeArray = info.GenericInstanceFields.Length == 1 && info.GenericInstanceFields[0].Type == typeof (Type[]); } } info.GenericArgumentCount = args == 0 ? -1 : args; } return info; }