BindToClass(ClassName: String): IForeClass;
ClassName. Class/interface/enumeration name.
The BindToClass method returns information about class/interface/enumeration with the specified name.
The method returns Null, if class/interface/enumeration with the specified name are not found in assembly.
Executing the example requires that the repository contains an assembly with the ASSM_TEST identifier. The CCalculate class is implemented in assembly.
Add links to the Fore, Metabase, and Xml system assemblies.
Sub UserProc;
Var
ForeService: IForeServices;
Runtime: IForeRuntime;
Assm: IForeAssembly;
FClass: IForeClass;
FSub: IForeSub;
i, j: Integer;
Begin
ForeService := MetabaseClass.Active As IForeServices;
Runtime := ForeService.GetRuntime;
//Load assembly
Assm := Runtime.BindToAssembly("ASSM_TEST");
//Get information about class procedures/functions
FClass := Assm.BindToClass("CCalculate");
j := FClass.SubsCount - 1;
For i := 0 To j Do
FSub := FClass.SubItem(i);
If FSub.IsConstructor Then
Debug.Write("Constructor: ");
Elseif FSub.IsStatic Then
If FSub.IsResult Then
Debug.Write("Static function: ");
Else
Debug.Write("Static procedure: ");
End If;
Else
If FSub.IsResult Then
Debug.Write("Function: ");
Else
Debug.Write("Procedure: ");
End If;
End If;
Debug.WriteLine(FSub.Name);
If FSub.XMLDocumentation <> Null Then
Debug.WriteLine("Comments:");
Debug.Indent;
PrintXml(FSub.XMLDocumentation);
Debug.Unindent;
End If;
If FSub.ModuleName <> "ASSM_TEST" Then
Debug.WriteLine("Explicit implementation in: " + FSub.ModuleName);
End If;
End For;
End Sub UserProc;
Sub PrintXml(_doc: IXmlDomDocument);
Var
_nodes: IXmlDomNodeList;
_node: IXmlDomNode;
_elem: IXmlDomElement;
Begin
_elem := _doc.documentElement;
Debug.WriteLine("Root node: " + _elem.nodeName);
_nodes := _elem.childNodes;
Debug.WriteLine("Root child count: " + _nodes.length.ToString);
Debug.WriteLine("Nodes: ");
Debug.Indent;
_node := _nodes.nextNode;
While _node <> Null Do
Debug.WriteLine("Name: " + _node.nodeName + ", Text: " + _node.text);
_node := _nodes.nextNode;
End While;
Debug.Unindent;
End Sub PrintXml;
On executing the example, the repository assembly with the specified identifier will be loaded to the execution environment. The development environment console will display information about procedures/functions/constructors implemented in the CCalculate class.
See also: