TypeInfo

From Xojo Documentation

Revision as of 18:56, 19 November 2009 by WikiSysop (talk) (1 revision)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


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.


Super Class

MemberInfo

Properties

Name Type Description
BaseType
Introduced 2008r2
TypeInfo Gets the parent TypeInfo object and allows you to navigate the type hierarchy from child to parent.
FullName 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.
HasElementType Boolean Compound datatypes have their own attributes as well as an element type.
IsArray Boolean True if the datatype is an array.
IsClass Boolean True if the datatype represents a class.
IsEnum Boolean True if the datatype represents an enumerated set of constants.
IsInterface Boolean True if the datatype represents a class interface.
IsPointer Boolean True if the datatype represents a Ptr or one of the other external pointer types.
IsPrimitive Boolean True if the datatype represents one of the primitive data types, i.e., Boolean, String, Color, and the numeric data types.
IsValueType 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.


Methods

Name Parameters Return Type Description
GetArrayRank 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.
GetConstructors
Introduced 2008r2
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.
GetElementType 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.
GetMethods MethodInfo() Returns an array of MethodInfo instances.
GetProperties PropertyInfo() Returns an array of PropertyInfo instances.
IsSubclassOf c as TypeInfo Boolean Returns True if the datatype is a subclass of the passed datatype.

 


Examples

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

Dim d as New Date 
Dim myProperties() as Introspection.PropertyInfo = _
Introspection.GetType(d).GetProperties
Dim myMethods() As Introspection.MethodInfo = _
Introspection.GetType(d).GetMethods


//display the properties...
For i as Integer=0 to UBound(myProperties)
ListBox1.AddRow myProperties(i).Name
Next

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

Dim ci() as Introspection.ConstructorInfo=ti.GetConstructors


f=ci(0).invoke


See Also

Introspection module; AttributeInfo, ConstructorInfo, MemberInfo, MethodInfo, ObjectIterator, ParameterInfo, PropertyInfo classes; GetTypeInfo function.