5 // Miguel de Icaza (miguel@ximian.com)
7 // (C) Ximian, Inc. http://www.ximian.com
11 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 using System
.Diagnostics
;
34 using System
.Reflection
;
35 using System
.Collections
;
36 using System
.Runtime
.InteropServices
;
37 using System
.Runtime
.CompilerServices
;
38 using System
.Globalization
;
43 [ClassInterface (ClassInterfaceType
.AutoDual
)]
44 public abstract class Type
: MemberInfo
, IReflect
{
46 internal RuntimeTypeHandle _impl
;
48 public static readonly char Delimiter
= '.';
49 public static readonly Type
[] EmptyTypes
= {};
50 public static readonly MemberFilter FilterAttribute
= new MemberFilter (FilterAttribute_impl
);
51 public static readonly MemberFilter FilterName
= new MemberFilter (FilterName_impl
);
52 public static readonly MemberFilter FilterNameIgnoreCase
= new MemberFilter (FilterNameIgnoreCase_impl
);
53 public static readonly object Missing
;
55 protected const BindingFlags DefaultBindingFlags
=
56 BindingFlags
.Public
| BindingFlags
.Static
| BindingFlags
.Instance
;
58 /* implementation of the delegates for MemberFilter */
59 static bool FilterName_impl (MemberInfo m
, object filterCriteria
)
61 string name
= (string) filterCriteria
;
62 return name
.Equals (m
.Name
);
65 static bool FilterNameIgnoreCase_impl (MemberInfo m
, object filterCriteria
)
67 string name
= (string) filterCriteria
;
68 if (name
.Length
!= m
.Name
.Length
)
71 return String
.Compare (name
, m
.Name
, true, CultureInfo
.InvariantCulture
) == 0;
74 static bool FilterAttribute_impl (MemberInfo m
, object filterCriteria
)
76 int flags
= ((IConvertible
)filterCriteria
).ToInt32 (null);
78 return ((int)((MethodInfo
)m
).Attributes
& flags
) != 0;
80 return ((int)((FieldInfo
)m
).Attributes
& flags
) != 0;
81 if (m
is PropertyInfo
)
82 return ((int)((PropertyInfo
)m
).Attributes
& flags
) != 0;
84 return ((int)((EventInfo
)m
).Attributes
& flags
) != 0;
93 /// The assembly where the type is defined.
95 public abstract Assembly Assembly
{
100 /// Gets the fully qualified name for the type including the
101 /// assembly name where the type is defined.
103 public abstract string AssemblyQualifiedName
{
108 /// Returns the Attributes associated with the type.
110 public TypeAttributes Attributes
{
112 return GetAttributeFlagsImpl ();
117 /// Returns the basetype for this type
119 public abstract Type BaseType
{
124 /// Returns the class that declares the member.
126 public override Type DeclaringType
{
135 public static Binder DefaultBinder
{
137 return Binder
.DefaultBinder
;
142 /// The full name of the type including its namespace
144 public abstract string FullName
{
148 public abstract Guid GUID
{
152 public bool HasElementType
{
154 return HasElementTypeImpl ();
158 public bool IsAbstract
{
160 return (Attributes
& TypeAttributes
.Abstract
) != 0;
164 public bool IsAnsiClass
{
166 return (Attributes
& TypeAttributes
.StringFormatMask
)
167 == TypeAttributes
.AnsiClass
;
171 public bool IsArray
{
173 return IsArrayImpl ();
177 public bool IsAutoClass
{
179 return (Attributes
& TypeAttributes
.StringFormatMask
) == TypeAttributes
.AutoClass
;
183 public bool IsAutoLayout
{
185 return (Attributes
& TypeAttributes
.LayoutMask
) == TypeAttributes
.AutoLayout
;
189 public bool IsByRef
{
191 return IsByRefImpl ();
195 public bool IsClass
{
198 // This code used to probe for "this == typeof (System.Enum)", but in
199 // The .NET Framework 1.0, the above test return false
201 if (this == typeof (System
.ValueType
))
205 return !type_is_subtype_of (this, typeof (System
.ValueType
), false);
209 public bool IsCOMObject
{
211 return IsCOMObjectImpl ();
215 public bool IsContextful
{
217 return IsContextfulImpl ();
223 return type_is_subtype_of (this, typeof (System
.Enum
), false) &&
224 this != typeof (System
.Enum
);
228 public bool IsExplicitLayout
{
230 return (Attributes
& TypeAttributes
.LayoutMask
) == TypeAttributes
.ExplicitLayout
;
234 public bool IsImport
{
236 return (Attributes
& TypeAttributes
.Import
) != 0;
240 public bool IsInterface
{
242 return (Attributes
& TypeAttributes
.ClassSemanticsMask
) == TypeAttributes
.Interface
;
246 public bool IsLayoutSequential
{
248 return (Attributes
& TypeAttributes
.LayoutMask
) == TypeAttributes
.SequentialLayout
;
252 public bool IsMarshalByRef
{
254 return IsMarshalByRefImpl ();
258 public bool IsNestedAssembly
{
260 return (Attributes
& TypeAttributes
.VisibilityMask
) == TypeAttributes
.NestedAssembly
;
264 public bool IsNestedFamANDAssem
{
266 return (Attributes
& TypeAttributes
.VisibilityMask
) == TypeAttributes
.NestedFamANDAssem
;
270 public bool IsNestedFamily
{
272 return (Attributes
& TypeAttributes
.VisibilityMask
) == TypeAttributes
.NestedFamily
;
276 public bool IsNestedFamORAssem
{
278 return (Attributes
& TypeAttributes
.VisibilityMask
) == TypeAttributes
.NestedFamORAssem
;
282 public bool IsNestedPrivate
{
284 return (Attributes
& TypeAttributes
.VisibilityMask
) == TypeAttributes
.NestedPrivate
;
288 public bool IsNestedPublic
{
290 return (Attributes
& TypeAttributes
.VisibilityMask
) == TypeAttributes
.NestedPublic
;
294 public bool IsNotPublic
{
296 return (Attributes
& TypeAttributes
.VisibilityMask
) == TypeAttributes
.NotPublic
;
300 public bool IsPointer
{
302 return IsPointerImpl ();
306 public bool IsPrimitive
{
308 return IsPrimitiveImpl ();
312 public bool IsPublic
{
314 return (Attributes
& TypeAttributes
.VisibilityMask
) == TypeAttributes
.Public
;
318 public bool IsSealed
{
320 return (Attributes
& TypeAttributes
.Sealed
) != 0;
324 public bool IsSerializable
{
326 // Enums and delegates are always serializable
327 return (Attributes
& TypeAttributes
.Serializable
) != 0 || IsEnum
||
328 type_is_subtype_of (this, typeof (System
.Delegate
), false);
332 public bool IsSpecialName
{
334 return (Attributes
& TypeAttributes
.SpecialName
) != 0;
338 public bool IsUnicodeClass
{
340 return (Attributes
& TypeAttributes
.StringFormatMask
) == TypeAttributes
.UnicodeClass
;
344 public bool IsValueType
{
346 return IsValueTypeImpl ();
350 public override MemberTypes MemberType
{
351 get {return MemberTypes.TypeInfo;}
354 #if NET_2_0 || BOOTSTRAP_NET_2_0
357 public abstract Module Module {get;}
359 public abstract string Namespace {get;}
361 public override Type ReflectedType
{
367 public abstract RuntimeTypeHandle TypeHandle {get;}
369 public ConstructorInfo TypeInitializer
{
371 return GetConstructorImpl (
372 BindingFlags
.Public
| BindingFlags
.NonPublic
| BindingFlags
.Static
,
374 CallingConventions
.Any
,
380 public abstract Type UnderlyingSystemType {get;}
382 public override bool Equals (object o
)
387 // TODO: return UnderlyingSystemType == o.UnderlyingSystemType;
388 Type cmp
= o
as Type
;
394 [MethodImplAttribute(MethodImplOptions
.InternalCall
)]
395 public extern bool Equals (Type type
);
397 [MethodImplAttribute(MethodImplOptions
.InternalCall
)]
398 private static extern Type
internal_from_handle (IntPtr handle
);
400 [MethodImplAttribute(MethodImplOptions
.InternalCall
)]
401 private static extern Type
internal_from_name (string name
, bool throwOnError
, bool ignoreCase
);
403 public static Type
GetType(string typeName
)
405 if (typeName
== null)
406 throw new ArgumentNullException ("typeName");
408 return internal_from_name (typeName
, false, false);
411 public static Type
GetType(string typeName
, bool throwOnError
)
413 if (typeName
== null)
414 throw new ArgumentNullException ("typeName");
416 Type type
= internal_from_name (typeName
, throwOnError
, false);
417 if (throwOnError
&& type
== null)
418 throw new TypeLoadException ("Error loading '" + typeName
+ "'");
423 public static Type
GetType(string typeName
, bool throwOnError
, bool ignoreCase
)
425 if (typeName
== null)
426 throw new ArgumentNullException ("typeName");
428 Type t
= internal_from_name (typeName
, throwOnError
, ignoreCase
);
429 if (throwOnError
&& t
== null)
430 throw new TypeLoadException ("Error loading '" + typeName
+ "'");
435 public static Type
[] GetTypeArray (object[] args
) {
437 throw new ArgumentNullException ("args");
440 ret
= new Type
[args
.Length
];
441 for (int i
= 0; i
< args
.Length
; ++i
)
442 ret
[i
] = args
[i
].GetType ();
446 [MethodImplAttribute(MethodImplOptions
.InternalCall
)]
447 public extern static TypeCode
GetTypeCode (Type type
);
450 public static Type
GetTypeFromCLSID (Guid clsid
)
452 throw new NotImplementedException ();
456 public static Type
GetTypeFromCLSID (Guid clsid
, bool throwOnError
)
458 throw new NotImplementedException ();
462 public static Type
GetTypeFromCLSID (Guid clsid
, string server
)
464 throw new NotImplementedException ();
468 public static Type
GetTypeFromCLSID (Guid clsid
, string server
, bool throwOnError
)
470 throw new NotImplementedException ();
473 public static Type
GetTypeFromHandle (RuntimeTypeHandle handle
)
475 return internal_from_handle (handle
.Value
);
479 public static Type
GetTypeFromProgID (string progID
)
481 throw new NotImplementedException ();
485 public static Type
GetTypeFromProgID (string progID
, bool throwOnError
)
487 throw new NotImplementedException ();
491 public static Type
GetTypeFromProgID (string progID
, string server
)
493 throw new NotImplementedException ();
497 public static Type
GetTypeFromProgID (string progID
, string server
, bool throwOnError
)
499 throw new NotImplementedException ();
502 public static RuntimeTypeHandle
GetTypeHandle (object o
)
504 return o
.GetType().TypeHandle
;
507 [MethodImplAttribute(MethodImplOptions
.InternalCall
)]
508 internal static extern bool type_is_subtype_of (Type a
, Type b
, bool check_interfaces
);
510 [MethodImplAttribute(MethodImplOptions
.InternalCall
)]
511 internal static extern bool type_is_assignable_from (Type a
, Type b
);
513 public virtual bool IsSubclassOf (Type c
)
518 return (this != c
) && type_is_subtype_of (this, c
, false);
521 public virtual Type
[] FindInterfaces (TypeFilter filter
, object filterCriteria
)
524 throw new ArgumentNullException ("filter");
526 ArrayList ifaces
= new ArrayList ();
527 foreach (Type iface
in GetInterfaces ()) {
528 if (filter (iface
, filterCriteria
))
532 return (Type
[]) ifaces
.ToArray (typeof (Type
));
535 public Type
GetInterface (string name
) {
536 return GetInterface (name
, false);
539 public abstract Type
GetInterface (string name
, bool ignoreCase
);
541 [MethodImplAttribute(MethodImplOptions
.InternalCall
)]
542 internal static extern void GetInterfaceMapData (Type t
, Type iface
, out MethodInfo
[] targets
, out MethodInfo
[] methods
);
544 public virtual InterfaceMapping
GetInterfaceMap (Type interfaceType
) {
545 InterfaceMapping res
;
546 if (interfaceType
== null)
547 throw new ArgumentNullException ("interfaceType");
548 if (!interfaceType
.IsInterface
)
549 throw new ArgumentException (Locale
.GetText ("Argument must be an interface."), "interfaceType");
550 res
.TargetType
= this;
551 res
.InterfaceType
= interfaceType
;
552 GetInterfaceMapData (this, interfaceType
, out res
.TargetMethods
, out res
.InterfaceMethods
);
553 if (res
.TargetMethods
== null)
554 throw new ArgumentException (Locale
.GetText ("Interface not found"), "interfaceType");
559 public abstract Type
[] GetInterfaces ();
561 public virtual bool IsAssignableFrom (Type c
)
569 return type_is_assignable_from (this, c
);
572 [MethodImplAttribute(MethodImplOptions
.InternalCall
)]
573 public extern virtual bool IsInstanceOfType (object o
);
575 public virtual int GetArrayRank ()
577 throw new NotSupportedException (); // according to MSDN
580 public abstract Type
GetElementType ();
582 public EventInfo
GetEvent (string name
)
584 return GetEvent (name
, DefaultBindingFlags
);
587 public abstract EventInfo
GetEvent (string name
, BindingFlags bindingAttr
);
589 public virtual EventInfo
[] GetEvents ()
591 return GetEvents (DefaultBindingFlags
);
594 public abstract EventInfo
[] GetEvents (BindingFlags bindingAttr
);
596 public FieldInfo
GetField( string name
)
598 return GetField (name
, DefaultBindingFlags
);
601 public abstract FieldInfo
GetField( string name
, BindingFlags bindingAttr
);
603 public FieldInfo
[] GetFields ()
605 return GetFields (DefaultBindingFlags
);
608 public abstract FieldInfo
[] GetFields (BindingFlags bindingAttr
);
610 public override int GetHashCode()
612 return (int)_impl
.Value
;
615 public MemberInfo
[] GetMember (string name
)
617 return GetMember (name
, DefaultBindingFlags
);
620 public virtual MemberInfo
[] GetMember (string name
, BindingFlags bindingAttr
)
622 return GetMember (name
, MemberTypes
.All
, bindingAttr
);
625 public virtual MemberInfo
[] GetMember (string name
, MemberTypes type
, BindingFlags bindingAttr
)
627 if ((bindingAttr
& BindingFlags
.IgnoreCase
) != 0)
628 return FindMembers (type
, bindingAttr
, FilterNameIgnoreCase
, name
);
630 return FindMembers (type
, bindingAttr
, FilterName
, name
);
633 public MemberInfo
[] GetMembers ()
635 return GetMembers (DefaultBindingFlags
);
638 public abstract MemberInfo
[] GetMembers (BindingFlags bindingAttr
);
640 public MethodInfo
GetMethod (string name
)
643 throw new ArgumentNullException ("name");
644 return GetMethodImpl (name
, DefaultBindingFlags
, null, CallingConventions
.Any
, null, null);
647 public MethodInfo
GetMethod (string name
, BindingFlags bindingAttr
)
650 throw new ArgumentNullException ("name");
652 return GetMethodImpl (name
, bindingAttr
, null, CallingConventions
.Any
, null, null);
655 public MethodInfo
GetMethod (string name
, Type
[] types
)
657 return GetMethod (name
, DefaultBindingFlags
, null, CallingConventions
.Any
, types
, null);
660 public MethodInfo
GetMethod (string name
, Type
[] types
, ParameterModifier
[] modifiers
)
662 return GetMethod (name
, DefaultBindingFlags
, null, CallingConventions
.Any
, types
, modifiers
);
665 public MethodInfo
GetMethod (string name
, BindingFlags bindingAttr
, Binder binder
,
666 Type
[] types
, ParameterModifier
[] modifiers
)
669 return GetMethod (name
, bindingAttr
, binder
, CallingConventions
.Any
, types
, modifiers
);
672 public MethodInfo
GetMethod (string name
, BindingFlags bindingAttr
, Binder binder
,
673 CallingConventions callConvention
, Type
[] types
, ParameterModifier
[] modifiers
)
676 throw new ArgumentNullException ("name");
678 throw new ArgumentNullException ("types");
680 for (int i
= 0; i
< types
.Length
; i
++)
681 if (types
[i
] == null)
682 throw new ArgumentNullException ("types");
684 return GetMethodImpl (name
, bindingAttr
, binder
, callConvention
, types
, modifiers
);
687 protected abstract MethodInfo
GetMethodImpl (string name
, BindingFlags bindingAttr
, Binder binder
,
688 CallingConventions callConvention
, Type
[] types
,
689 ParameterModifier
[] modifiers
);
691 public MethodInfo
[] GetMethods ()
693 return GetMethods (DefaultBindingFlags
);
696 public abstract MethodInfo
[] GetMethods (BindingFlags bindingAttr
);
698 public Type
GetNestedType (string name
)
700 return GetNestedType (name
, DefaultBindingFlags
);
703 public abstract Type
GetNestedType (string name
, BindingFlags bindingAttr
);
705 public Type
[] GetNestedTypes ()
707 return GetNestedTypes (DefaultBindingFlags
);
710 public abstract Type
[] GetNestedTypes (BindingFlags bindingAttr
);
713 public PropertyInfo
[] GetProperties ()
715 return GetProperties (DefaultBindingFlags
);
718 public abstract PropertyInfo
[] GetProperties (BindingFlags bindingAttr
);
721 public PropertyInfo
GetProperty (string name
)
724 throw new ArgumentNullException ("name");
726 return GetPropertyImpl (name
, DefaultBindingFlags
, null, null, new Type
[0], null);
729 public PropertyInfo
GetProperty (string name
, BindingFlags bindingAttr
)
732 throw new ArgumentNullException ("name");
733 return GetPropertyImpl (name
, bindingAttr
, null, null, new Type
[0], null);
736 public PropertyInfo
GetProperty (string name
, Type returnType
)
739 throw new ArgumentNullException ("name");
740 return GetPropertyImpl (name
, DefaultBindingFlags
, null, returnType
, new Type
[0], null);
743 public PropertyInfo
GetProperty (string name
, Type
[] types
)
745 return GetProperty (name
, DefaultBindingFlags
, null, null, types
, null);
748 public PropertyInfo
GetProperty (string name
, Type returnType
, Type
[] types
)
750 return GetProperty (name
, DefaultBindingFlags
, null, returnType
, types
, null);
753 public PropertyInfo
GetProperty( string name
, Type returnType
, Type
[] types
, ParameterModifier
[] modifiers
)
755 return GetProperty (name
, DefaultBindingFlags
, null, returnType
, types
, modifiers
);
758 public PropertyInfo
GetProperty (string name
, BindingFlags bindingAttr
, Binder binder
, Type returnType
,
759 Type
[] types
, ParameterModifier
[] modifiers
)
762 throw new ArgumentNullException ("name");
764 throw new ArgumentNullException ("types");
766 return GetPropertyImpl (name
, bindingAttr
, binder
, returnType
, types
, modifiers
);
769 protected abstract PropertyInfo
GetPropertyImpl (string name
, BindingFlags bindingAttr
, Binder binder
,
770 Type returnType
, Type
[] types
, ParameterModifier
[] modifiers
);
772 protected abstract ConstructorInfo
GetConstructorImpl (BindingFlags bindingAttr
,
774 CallingConventions callConvention
,
776 ParameterModifier
[] modifiers
);
778 protected abstract TypeAttributes
GetAttributeFlagsImpl ();
779 protected abstract bool HasElementTypeImpl ();
780 protected abstract bool IsArrayImpl ();
781 protected abstract bool IsByRefImpl ();
782 protected abstract bool IsCOMObjectImpl ();
783 protected abstract bool IsPointerImpl ();
784 protected abstract bool IsPrimitiveImpl ();
786 [MethodImplAttribute(MethodImplOptions
.InternalCall
)]
787 internal static extern bool IsArrayImpl (Type type
);
789 protected virtual bool IsValueTypeImpl ()
791 if (this == typeof (Enum
) || this == typeof (ValueType
))
794 return IsSubclassOf (typeof (ValueType
));
797 protected virtual bool IsContextfulImpl ()
799 return typeof (ContextBoundObject
).IsAssignableFrom (this);
802 protected virtual bool IsMarshalByRefImpl ()
804 return typeof (MarshalByRefObject
).IsAssignableFrom (this);
807 public ConstructorInfo
GetConstructor (Type
[] types
)
809 return GetConstructorImpl (
810 DefaultBindingFlags
, null, CallingConventions
.Any
, types
, null);
813 public ConstructorInfo
GetConstructor (BindingFlags bindingAttr
, Binder binder
,
814 Type
[] types
, ParameterModifier
[] modifiers
)
816 return GetConstructorImpl (
817 bindingAttr
, binder
, CallingConventions
.Any
, types
, modifiers
);
820 public ConstructorInfo
GetConstructor (BindingFlags bindingAttr
, Binder binder
,
821 CallingConventions callConvention
,
822 Type
[] types
, ParameterModifier
[] modifiers
)
825 throw new ArgumentNullException ("types");
827 return GetConstructorImpl (bindingAttr
, binder
, callConvention
, types
, modifiers
);
830 public ConstructorInfo
[] GetConstructors ()
832 return GetConstructors (BindingFlags
.Public
| BindingFlags
.Instance
);
835 public abstract ConstructorInfo
[] GetConstructors (BindingFlags bindingAttr
);
837 public virtual MemberInfo
[] GetDefaultMembers ()
839 object [] att
= GetCustomAttributes (typeof (DefaultMemberAttribute
), true);
841 return new MemberInfo
[0];
843 MemberInfo
[] member
= GetMember (((DefaultMemberAttribute
) att
[0]).MemberName
);
844 return (member
!= null) ? member
: new MemberInfo
[0];
847 public virtual MemberInfo
[] FindMembers (MemberTypes memberType
, BindingFlags bindingAttr
,
848 MemberFilter filter
, object filterCriteria
)
851 ArrayList l
= new ArrayList ();
853 // Console.WriteLine ("FindMembers for {0} (Type: {1}): {2}",
854 // this.FullName, this.GetType().FullName, this.obj_address());
856 if ((memberType
& MemberTypes
.Constructor
) != 0) {
857 ConstructorInfo
[] c
= GetConstructors (bindingAttr
);
858 if (filter
!= null) {
859 foreach (MemberInfo m
in c
) {
860 if (filter (m
, filterCriteria
))
867 if ((memberType
& MemberTypes
.Event
) != 0) {
868 EventInfo
[] c
= GetEvents (bindingAttr
);
869 if (filter
!= null) {
870 foreach (MemberInfo m
in c
) {
871 if (filter (m
, filterCriteria
))
878 if ((memberType
& MemberTypes
.Field
) != 0) {
879 FieldInfo
[] c
= GetFields (bindingAttr
);
880 if (filter
!= null) {
881 foreach (MemberInfo m
in c
) {
882 if (filter (m
, filterCriteria
))
889 if ((memberType
& MemberTypes
.Method
) != 0) {
890 MethodInfo
[] c
= GetMethods (bindingAttr
);
891 if (filter
!= null) {
892 foreach (MemberInfo m
in c
) {
893 if (filter (m
, filterCriteria
))
900 if ((memberType
& MemberTypes
.Property
) != 0) {
904 if (filter
!= null) {
906 while ((l
.Count
== count
) && (ptype
!= null)) {
907 c
= ptype
.GetProperties (bindingAttr
);
908 foreach (MemberInfo m
in c
) {
909 if (filter (m
, filterCriteria
))
912 ptype
= ptype
.BaseType
;
915 c
= GetProperties (bindingAttr
);
919 if ((memberType
& MemberTypes
.NestedType
) != 0) {
920 Type
[] c
= GetNestedTypes (bindingAttr
);
921 if (filter
!= null) {
922 foreach (MemberInfo m
in c
) {
923 if (filter (m
, filterCriteria
)) {
931 result
= new MemberInfo
[l
.Count
];
937 [DebuggerStepThrough
]
938 public object InvokeMember (string name
, BindingFlags invokeAttr
, Binder binder
, object target
, object[] args
)
940 return InvokeMember (name
, invokeAttr
, binder
, target
, args
, null, null, null);
944 [DebuggerStepThrough
]
945 public object InvokeMember (string name
, BindingFlags invokeAttr
, Binder binder
,
946 object target
, object[] args
, CultureInfo culture
)
948 return InvokeMember (name
, invokeAttr
, binder
, target
, args
, null, culture
, null);
951 public abstract object InvokeMember (string name
, BindingFlags invokeAttr
,
952 Binder binder
, object target
, object[] args
,
953 ParameterModifier
[] modifiers
,
954 CultureInfo culture
, string[] namedParameters
);
956 public override string ToString()
961 internal object[] GetPseudoCustomAttributes () {
964 /* StructLayoutAttribute is not returned by MS.NET */
971 object[] attrs
= new object [count
];
975 attrs
[count
++] = new SerializableAttribute ();
980 #if NET_2_0 || BOOTSTRAP_NET_2_0
981 public abstract Type
[] GetGenericArguments ();
983 public abstract bool HasGenericArguments
{
987 public abstract bool ContainsGenericParameters
{
991 public extern bool IsGenericTypeDefinition
{
992 [MethodImplAttribute(MethodImplOptions
.InternalCall
)]
996 [MethodImplAttribute(MethodImplOptions
.InternalCall
)]
997 extern Type
GetGenericTypeDefinition_impl ();
999 public virtual Type
GetGenericTypeDefinition ()
1001 Type res
= GetGenericTypeDefinition_impl ();
1003 throw new InvalidOperationException ();
1008 public extern bool IsGenericInstance
{
1009 [MethodImplAttribute(MethodImplOptions
.InternalCall
)]
1013 [MethodImplAttribute(MethodImplOptions
.InternalCall
)]
1014 static extern Type
BindGenericParameters (Type gt
, Type
[] types
);
1016 public Type
BindGenericParameters (Type
[] types
)
1019 throw new ArgumentNullException ("types");
1020 foreach (Type t
in types
) {
1022 throw new ArgumentNullException ("types");
1024 Type res
= BindGenericParameters (this, types
);
1026 throw new TypeLoadException ();
1030 public abstract bool IsGenericParameter
{
1034 [MethodImplAttribute(MethodImplOptions
.InternalCall
)]
1035 extern int GetGenericParameterPosition ();
1037 public virtual int GenericParameterPosition
{
1039 int res
= GetGenericParameterPosition ();
1041 throw new InvalidOperationException ();
1046 [MethodImplAttribute(MethodImplOptions
.InternalCall
)]
1047 extern GenericParameterAttributes
GetGenericParameterAttributes ();
1049 public virtual GenericParameterAttributes GenericParameterAttributes
{
1051 if (!IsGenericParameter
)
1052 throw new InvalidOperationException ();
1054 return GetGenericParameterAttributes ();
1058 [MethodImplAttribute(MethodImplOptions
.InternalCall
)]
1059 extern Type
[] GetGenericParameterConstraints_impl ();
1061 public virtual Type
[] GetGenericParameterConstraints ()
1063 if (!IsGenericParameter
)
1064 throw new InvalidOperationException ();
1066 return GetGenericParameterConstraints_impl ();
1069 public abstract MethodInfo DeclaringMethod
{
1073 [MethodImplAttribute(MethodImplOptions
.InternalCall
)]
1074 extern Type
make_array_type (int rank
);
1076 public virtual Type
MakeArrayType ()
1078 return MakeArrayType (1);
1081 public virtual Type
MakeArrayType (int rank
)
1084 throw new IndexOutOfRangeException ();
1085 return make_array_type (rank
);
1088 [MethodImplAttribute(MethodImplOptions
.InternalCall
)]
1089 extern Type
make_byref_type ();
1091 public virtual Type
MakeByRefType ()
1093 return make_byref_type ();
1096 [MethodImplAttribute(MethodImplOptions
.InternalCall
)]
1097 public extern virtual Type
MakePointerType ();
1100 public static Type
ReflectionOnlyGetType (string typeName
,
1101 bool throwIfNotFound
,
1104 throw new NotImplementedException ();
1107 [MethodImplAttribute(MethodImplOptions
.InternalCall
)]
1108 extern void GetPacking (out int packing
, out int size
);
1110 public virtual StructLayoutAttribute StructLayoutAttribute
{
1114 if (IsLayoutSequential
)
1115 kind
= LayoutKind
.Sequential
;
1116 else if (IsExplicitLayout
)
1117 kind
= LayoutKind
.Explicit
;
1119 kind
= LayoutKind
.Auto
;
1121 StructLayoutAttribute attr
= new StructLayoutAttribute (kind
);
1124 attr
.CharSet
= CharSet
.Unicode
;
1125 else if (IsAnsiClass
)
1126 attr
.CharSet
= CharSet
.Ansi
;
1128 attr
.CharSet
= CharSet
.Auto
;
1130 if (kind
!= LayoutKind
.Auto
)
1131 GetPacking (out attr
.Pack
, out attr
.Size
);