public ConstructorInfo GetConstructor(Type[] parameters) { var ci = GenericsReflection.GetConstructor(this, parameters); if (ci != null) { return(ci); } var typeDefParams = new Type[parameters.Length]; for (int i = 0; i < parameters.Length; ++i) { typeDefParams[i] = parameters[i].EnsureTypeDef(); } try { return(new ConstructorInfo(JavaGetConstructor(typeDefParams))); } catch (NoSuchMethodException) { return(null); } }
/// <summary> /// Gets all constructors of this type that match the given binding flags, /// declared in this class. /// </summary> public ConstructorInfo[] GetConstructors(BindingFlags flags) { // note that unlike the other member retrival operations // GetConstructors never searches base classes. return(GenericsReflection.GetConstructors(this, flags) ?? JavaGetDeclaredConstructors() .Select(ctor => new ConstructorInfo(ctor)) .Where(ctor => IsMatch(ctor, flags))); }
public static MethodInfo GetDeclaredMethod(this Type type, string name, Type[] parameters) { if (type == null) { throw new ArgumentNullException("type"); } return(GenericsReflection.GetMethod(type, name, Type.BindFlags.DeclaredMembers, parameters)); }
public static IEnumerable <MethodInfo> GetRuntimeMethods(this Type type) { if (type == null) { throw new ArgumentNullException("type"); } return(GenericsReflection.GetMethods(type, Type.BindFlags.AllMembers)); }
/// <summary> /// In contrast to GetType(), which returns the Java-Runtime type, this method /// returns a type tht can properly be used in reflection: Boxed types return their /// primitive counterparts, and generic instances have their proper generic /// information. /// </summary> public Type GetTypeReflectionSafe() { // We have to make sure we return the correct primitive type // if the object was boxed. var type = JavaGetClass(); if (type == TypeHelper.BooleanType()) { return(typeof(bool)); } if (type == TypeHelper.CharacterType()) { return(typeof(char)); } if (type == TypeHelper.ByteType()) { return(typeof(byte)); } if (type == TypeHelper.ShortType()) { return(typeof(short)); } if (type == TypeHelper.IntegerType()) { return(typeof(int)); } if (type == TypeHelper.LongType()) { return(typeof(long)); } if (type == TypeHelper.FloatType()) { return(typeof(float)); } if (type == TypeHelper.DoubleType()) { return(typeof(double)); } return(GenericsReflection.GetReflectionSafeType(type, this)); }
private Type EnsureTypeDef() { return(GenericsReflection.EnsureTypeDef(this)); }
/// <summary> /// Gets all fields of this type that match the given binding flags. /// </summary> public FieldInfo[] GetFields(BindingFlags flags) { return(GenericsReflection.GetFields(this, flags)); }
public PropertyInfo[] GetDeclaredProperties() { return(PropertyInfoProvider.GetProperties(GenericsReflection.EnsureTypeDef(this), this)); }
public /*virtual*/ bool IsAssignableFrom(Type other) { return(GenericsReflection.IsAssignableFrom(this, other)); }
public MethodInfo GetMethod(string name) { return(GenericsReflection.GetMethod(this, name, BindFlags.PublicMembers, null)); }
public MethodInfo GetMethod(string name, Type[] parameters) { return(GenericsReflection.GetMethod(this, name, BindFlags.PublicMembers, parameters)); }
public Type GetGenericTypeDefinition() { return(GenericsReflection.GetGenericTypeDefinition(this)); }
/// <summary> /// Gets all methods of this type that match the given binding flags. /// </summary> public MethodInfo[] GetMethods(BindingFlags flags) { return(GenericsReflection.GetMethods(this, flags).ToArray()); }
/// <summary> /// will return the correct count. For nullable types, /// will return the underlying type. /// for other types the count will be right, but /// elements are all typeof(object) /// </summary> /// <returns></returns> public Type[] GetGenericArguments() { return(GenericsReflection.GetGenericArguments(this)); }
public FieldInfo GetField(string name, BindingFlags flags) { return(GenericsReflection.GetField(this, name, flags)); }
public FieldInfo GetField(string name) { return(GenericsReflection.GetField(this, name, BindFlags.PublicMembers)); }
/// <summary> /// Gets all public fields of this type. /// </summary> public FieldInfo[] GetFields() { return(GenericsReflection.GetFields(this, BindFlags.PublicMembers)); }
/// <summary> /// This will only work with .NET types not java types. /// <para> /// The returned type can only be used in Activator.CreateInstance, /// and is otherwise useless, except if this is Nullable[T]. /// /// In particular the class name, methods, fields, constructors and /// properties as well as the superclass and implemented interfaces can /// all not be retrieved from this type. /// </para> /// </summary> public Type MakeGenericType(params Type[] types) { return(GenericsReflection.MakeGenericType(this, types)); }
/// <summary> /// Gets all public methods of this type. /// </summary> public MethodInfo[] GetMethods() { return(GenericsReflection.GetMethods(this, BindFlags.PublicMembers) .ToArray()); }
public Type[] GetInterfaces() { return(GenericsReflection.GetInterfaces(this)); }