Class

TypeInfo


Description

Gets information about a program's structure. It is an abstract class whose properties and functions describe all the attributes or members a datatype might have.

Property descriptions


TypeInfo.BaseType

BaseType As TypeInfo

Gets the parent TypeInfo object and allows you to navigate the type hierarchy from child to parent.

This property is read-only.


TypeInfo.FullName

FullName As String

The full name of the item, including the module path. If two different classes in different modules have the same name, then the FullName property will differentiate them. It is a globally unique identifier for the datatype.

This property is read-only.


TypeInfo.HasElementType

HasElementType As Boolean

Compound datatypes have their own attributes as well as an element type.

This property is read-only.


TypeInfo.IsArray

IsArray As Boolean

True if the datatype is an array.

This property is read-only.


TypeInfo.IsClass

IsClass As Boolean

True if the datatype represents a class.

This property is read-only.


TypeInfo.IsEnum

IsEnum As Boolean

True if the datatype represents an enumerated set of constants.

This property is read-only.


TypeInfo.IsInterface

IsInterface As Boolean

True if the datatype represents a class interface.

This property is read-only.


TypeInfo.IsPointer

IsPointer As Boolean

True if the datatype represents a Ptr or one of the other external pointer types.

This property is read-only.


TypeInfo.IsPrimitive

IsPrimitive As Boolean

True if the datatype represents one of the primitive data types, i.e., Boolean, String, Color, and the numeric data types.

This property is read-only.


TypeInfo.IsPrivate

IsPrivate As Boolean

If True, the item has Private scope.

This property is read-only.

The following example checks the IsPrivate property before taking an action.

Var d As New DateTime = DateTime.Now
For Each prop As Introspection.PropertyInfo In Introspection.GetType(d).GetProperties
  If prop.IsPrivate Then
    // take an action here..
  End If
Next

TypeInfo.IsProtected

IsProtected As Boolean

Is True, the item has Protected scope.

This property is read-only.

Var d As New DateTime = DateTime.Now
For Each prop As Introspection.PropertyInfo In Introspection.GetType(d).GetProperties
  If prop.IsProtected Then
    // take an action here..
  End If
Next

TypeInfo.IsPublic

IsPublic As Boolean

If True, the item has Public scope.

This property is read-only.

This example checks the IsPublic property before taking an action.

Var d As New DateTime = DateTime.Now
For Each prop As Introspection.PropertyInfo In Introspection.GetType(d).GetProperties
  If prop.IsPublic Then
    // take an action here..
  End If
Next

TypeInfo.IsValueType

IsValueType As Boolean

True if the datatype represents a value type. Value types are those which are not references. Assignment copies the value itself, rather than a reference to a piece of data. Primitive, pointer, structure, and enum types are all value types.

This property is read-only.


TypeInfo.Name

Name As String

The name of the item. This is only the class name. To get the full namespace path, use FullName instead.

This property is read-only.

This code gets the list of properties for the passed type instance.

Var d As DateTime = DateTime.Now
For Each prop As Introspection.PropertyInfo In Introspection.GetType(d).GetProperties
  ListBox1.AddRow(prop.Name)
Next

Method descriptions


TypeInfo.GetArrayRank

GetArrayRank As Integer

Returns the number of dimensions of the item. GetArrayRank is valid only if IsArray is True. If the datatype is not an array, then calling GetArrayRank will raise an exception.


TypeInfo.GetAttributes

GetAttributes As AttributeInfo()

Returns an array of AttributeInfo objects.

The following gets the attributes of window1.

Var myAttributes() As Introspection.AttributeInfo = Introspection.GetType(Window1).GetAttributes

TypeInfo.GetConstructors

GetConstructors As ConstructorInfo()

Returns an array of ConstructorInfo about the datatype. If the TypeInfo represents a class, then the returned array will contain constructors. Otherwise, it will be empty.


TypeInfo.GetElementType

GetElementType As TypeInfo

Returns the type of the element. GetElementType is valid only if the datatype has an element type, i.e., if HasElementType is True. If the datatype does not have an element type, then calling GetElementType will raise an exception.


TypeInfo.GetMethods

GetMethods As MethodInfo()

Returns an array of MethodInfo instances.

TypeInfo.GetMethods lists parent methods which are overridden, resulting in duplicates in the list when you call GetMethods on a subclass.


TypeInfo.GetProperties

GetProperties As PropertyInfo()

Returns an array of PropertyInfo instances.


TypeInfo.IsSubclassOf

IsSubclassOf(c As TypeInfo) As Boolean

Returns True if the datatype is a subclass of the passed datatype.

Notes

TypeInfo is part of the Introspection namespace (module) so you'll have to prefix it and refer to it as "Introspection.TypeInfo".

Sample code

The following returns PropertyInfo and MethodInfo arrays containing the properties and methods of the passed class instance.

Var d As DateTime = DateTime.Now
Var myProperties() As Introspection.PropertyInfo = Introspection.GetType(d).GetProperties
Var myMethods() As Introspection.MethodInfo = Introspection.GetType(d).GetMethods
// display the properties...
For Each prop As Introspection.PropertyInfo In myProperties
  ListBox1.AddRow(prop.Name)
Next

This example gets the ConstructorInfo for the FolderItem class and creates a new instance of a FolderItem.

Var ti As Introspection.Typeinfo = GetTypeInfo(FolderItem)
Var ci() As Introspection.ConstructorInfo = ti.GetConstructors
Var f As FolderItem
f = ci(0).Invoke

Compatibility

All project types on all supported operating systems.