Difference between revisions of "ConstructorInfo"

From Xojo Documentation

(Examples)
 
 
(20 intermediate revisions by 7 users not shown)
Line 1: Line 1:
 +
{{ClassBox
 +
| super=[[MemberInfo]]
 +
| platform=all
 +
| scope=global
 +
}}
 +
{{Description
 +
|text=Contains information about the constructors for a class via the [[Introspection]] system.
 +
}}
  
 +
<dynamicTable id="Properties" super="MemberInfo" class="propertyTable" title="Properties" columns="3">
 +
</dynamicTable>
  
=='''Description'''==
 
Contains information about the constructors for a class via the [[Introspection|Introspection]] system.
 
  
 +
<dynamicTable id="Methods" super="MemberInfo" class="methodTable" title="Methods" columns="3">
 +
{{Method | name=GetParameters | description=GetParameters() as ParameterInfo()&#x0A;Returns an array of ParameterInfo items }}
 +
{{Method | name=Invoke | params=[params() as [[Variant]]]  | returntype=Datatype of the object being instantiated. | modifiedinversion=2008r2 | description=Invoke([params() as Variant] ) as Datatype of the object being instantiated.&#x0A;Invokes the constructor }}
 +
</dynamicTable>
  
 +
== Sample Code ==
 +
This code uses the Invoke method to call the FolderItem constructor that takes no parameters:
 +
<rbcode>
 +
Var ti As Introspection.TypeInfo = GetTypeInfo(FolderItem)
 +
Var ci() As Introspection.ConstructorInfo = ti.GetConstructors
  
=='''Super Class'''==
+
Var f As FolderItem
[[MemberInfo|MemberInfo]]
+
f = ci(0).Invoke
 +
</rbcode>
  
=='''Properties'''==
+
==See Also==
 +
[[Introspection]] module; [[AttributeInfo]], [[MemberInfo]], [[MethodInfo]], [[ObjectIterator]], [[ParameterInfo]], [[PropertyInfo]], [[TypeInfo]] classes; [[GetTypeInfo]] function.
  
{| cellpadding="8" cellspacing="0" border="1"
+
[http://developer.xojo.com/xojo-introspection-constructorinfo Xojo.Introspection.ConstructorInfo]
  
! width=10%  style="background-color:#e0e0e0" | Name
+
[[Category:Language_Classes]]
 
+
[[Category:Language_Introspection]]
! width=15%  style="background-color:#e0e0e0" | Type
 
 
 
! width=55%  style="background-color:#e0e0e0" | Description
 
|-
 
|ReturnType
 
 
 
|[[TypeInfo|TypeInfo]]
 
|If the constructor returns a value, this is the datatype of the returned value. If the method does not return a value, ReturnType is [[Nil|Nil]].
 
 
 
|-
 
|}
 
 
 
 
 
=='''Methods'''==
 
 
 
{| cellpadding="8" cellspacing="0" border="1"
 
 
 
! width=10%  style="background-color:#e0e0e0" | Name
 
 
 
! width=20%  style="background-color:#e0e0e0" | Parameters
 
 
 
! width=25%  style="background-color:#e0e0e0" | Return Type
 
 
 
! width=55%  style="background-color:#e0e0e0" | Description
 
|-
 
|GetParameters
 
 
 
|
 
|[[ParameterInfoList|ParameterInfo()]]
 
|Returns an array of [[ParameterInfo|ParameterInfo]] items. Use GetParameters to obtain datatype information on the constructor's parameters.
 
 
 
|-
 
|<div style="font-style:italic; color:green;">Changed 2008r2</div>Invoke
 
 
 
|[params() as [[Variant|Variant]]]
 
 
 
|Datatype of the object being instantiated.
 
 
 
|Invokes the constructor. Pass the optional array of variants for the constructor's parameter values, if any. You will get an [[OutOfBoundsException|OutOfBoundsException]] if the number of parameters does not match or an [[IllegalCastException|IllegalCastException]] if the types do not match.
 
 
 
|-
 
|}
 
 
 
 
 
=='''Examples'''==
 
This example gets the '''ConstructorInfo''' for the [[FolderItem|FolderItem]] class. The Invoke method is used to create a new instance based on the constructor that takes no parameters.
 
 
 
<div style="background-color:#d0d0d0; padding-left:30px">[[Dim|Dim]] ti as [[Introspection|Introspection]].[[TypeInfo|Typeinfo]]=[[GetTypeInfo|GetTypeinfo]]([[FolderItem|FolderItem]])
 
<br /></div>
 
<div style="background-color:#d0d0d0; padding-left:30px">[[Dim|Dim]] ci() as [[Introspection|Introspection]].ConstructorInfo=ti.GetConstructors
 
<br /></div>
 
<div style="background-color:#d0d0d0; padding-left:30px"><br /></div>
 
<div style="background-color:#d0d0d0; padding-left:30px">[[Dim|Dim]] f as [[FolderItem|FolderItem]]<br /></div>
 
<div style="background-color:#d0d0d0; padding-left:30px">f=ci(0).Invoke
 
<br /></div>
 
 
 
=='''See Also'''==
 
[[Introspection|Introspection]] module; [[AttributeInfo|AttributeInfo]], [[MemberInfo|MemberInfo]], [[MethodInfo|MethodInfo]], [[ObjectIterator|ObjectIterator]], [[ParameterInfo|ParameterInfo]], [[PropertyInfo|PropertyInfo]], [[TypeInfo|TypeInfo]] classes; [[GetTypeInfo|GetTypeInfo]] function.
 
 
 
 
 
[[Category:Classes]]
 
[[Category:Introspection]]
 

Latest revision as of 21:03, 28 January 2021

Class (inherits from MemberInfo)

Contains information about the constructors for a class via the Introspection system.

Properties
IsPrivate fa-lock-32.png IsPublic fa-lock-32.png
IsProtected fa-lock-32.png Name fa-lock-32.png


Methods
GetAttributes GetParameters Invoke

Sample Code

This code uses the Invoke method to call the FolderItem constructor that takes no parameters:

Var ti As Introspection.TypeInfo = GetTypeInfo(FolderItem)
Var ci() As Introspection.ConstructorInfo = ti.GetConstructors

Var f As FolderItem
f = ci(0).Invoke

See Also

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

Xojo.Introspection.ConstructorInfo