예제 #1
0
파일: Type.cs 프로젝트: luozhiping1987/api
        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);
            }
        }
예제 #2
0
파일: Type.cs 프로젝트: luozhiping1987/api
 /// <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)));
 }
예제 #3
0
        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));
        }
예제 #4
0
        public static IEnumerable <MethodInfo> GetRuntimeMethods(this Type type)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }

            return(GenericsReflection.GetMethods(type, Type.BindFlags.AllMembers));
        }
예제 #5
0
        /// <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));
        }
예제 #6
0
파일: Type.cs 프로젝트: luozhiping1987/api
 private Type EnsureTypeDef()
 {
     return(GenericsReflection.EnsureTypeDef(this));
 }
예제 #7
0
파일: Type.cs 프로젝트: luozhiping1987/api
 /// <summary>
 /// Gets all fields of this type that match the given binding flags.
 /// </summary>
 public FieldInfo[] GetFields(BindingFlags flags)
 {
     return(GenericsReflection.GetFields(this, flags));
 }
예제 #8
0
파일: Type.cs 프로젝트: luozhiping1987/api
 public PropertyInfo[] GetDeclaredProperties()
 {
     return(PropertyInfoProvider.GetProperties(GenericsReflection.EnsureTypeDef(this), this));
 }
예제 #9
0
파일: Type.cs 프로젝트: luozhiping1987/api
 public /*virtual*/ bool IsAssignableFrom(Type other)
 {
     return(GenericsReflection.IsAssignableFrom(this, other));
 }
예제 #10
0
파일: Type.cs 프로젝트: luozhiping1987/api
 public MethodInfo GetMethod(string name)
 {
     return(GenericsReflection.GetMethod(this, name, BindFlags.PublicMembers, null));
 }
예제 #11
0
파일: Type.cs 프로젝트: luozhiping1987/api
 public MethodInfo GetMethod(string name, Type[] parameters)
 {
     return(GenericsReflection.GetMethod(this, name, BindFlags.PublicMembers, parameters));
 }
예제 #12
0
파일: Type.cs 프로젝트: luozhiping1987/api
 public Type GetGenericTypeDefinition()
 {
     return(GenericsReflection.GetGenericTypeDefinition(this));
 }
예제 #13
0
파일: Type.cs 프로젝트: luozhiping1987/api
 /// <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());
 }
예제 #14
0
파일: Type.cs 프로젝트: luozhiping1987/api
 /// <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));
 }
예제 #15
0
파일: Type.cs 프로젝트: luozhiping1987/api
 public FieldInfo GetField(string name, BindingFlags flags)
 {
     return(GenericsReflection.GetField(this, name, flags));
 }
예제 #16
0
파일: Type.cs 프로젝트: luozhiping1987/api
 public FieldInfo GetField(string name)
 {
     return(GenericsReflection.GetField(this, name, BindFlags.PublicMembers));
 }
예제 #17
0
파일: Type.cs 프로젝트: luozhiping1987/api
 /// <summary>
 /// Gets all public fields of this type.
 /// </summary>
 public FieldInfo[] GetFields()
 {
     return(GenericsReflection.GetFields(this, BindFlags.PublicMembers));
 }
예제 #18
0
파일: Type.cs 프로젝트: luozhiping1987/api
 /// <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));
 }
예제 #19
0
파일: Type.cs 프로젝트: luozhiping1987/api
 /// <summary>
 /// Gets all public methods of this type.
 /// </summary>
 public MethodInfo[] GetMethods()
 {
     return(GenericsReflection.GetMethods(this, BindFlags.PublicMembers)
            .ToArray());
 }
예제 #20
0
파일: Type.cs 프로젝트: luozhiping1987/api
 public Type[] GetInterfaces()
 {
     return(GenericsReflection.GetInterfaces(this));
 }