BindToMethod(MethodName: String): IForeSub;
BindToMethod(MethodName: String): Prognoz.Platform.Interop.KeFore.IForeSub;
MethodName. Procedure/function name.
The BindToMethod method returns information about procedure/function with the specified name.
The method returns Null, if procedure/function with the specified name is not found in class.
Executing the example requires that the repository contains an assembly with the ASSM_TEST identifier. The CCalculate class is implemented in the assembly, the class contains the Calculate function.
Add a link to the Fore, Metabase system assembly.
Sub UserProc;
Var
ForeService: IForeServices;
Runtime: IForeRuntime;
Assm: IForeAssembly;
FClass: IForeClass;
FSub: IForeSub;
Begin
ForeService := MetabaseClass.Active As IForeServices;
Runtime := ForeService.GetRuntime;
//Load assembly
Runtime.LoadAssembly("ASSM_TEST");
Assm := Runtime.BindToAssembly("ASSM_TEST");
//Get class
FClass := Assm.BindToClass("CCalculate");
//Get function
FSub := FClass.BindToMethod("Calculate");
//Specify class instance for which function will be executed
FSub.Self := FClass.CreateObject;
//Function execution
FSub.Invoke;
//Display result
If FSub.IsResult Then
Debug.WriteLine(FSub.ResultValue);
End If;
End Sub UserProc;
Imports Prognoz.Platform.Interop.Fore;
Imports Prognoz.Platform.Interop.Metabase;
Public Shared Sub Main(Params: StartParams);
Var
ForeService: IForeServices;
Runtime: IForeRuntime;
Assm: IForeAssembly;
FClass: IForeClass;
FSub: IForeSub;
Begin
ForeService := Params.Metabase As IForeServices;
Runtime := ForeService.GetRuntime();
//Load assembly
Runtime.LoadAssembly("ASSM_TEST");
Assm := Runtime.BindToAssembly("ASSM_TEST");
//Get class
FClass := Assm.BindToClass("CCalculate");
//Get function
FSub := FClass.BindToMethod("Calculate");
//Specify class instance for which function will be executed
FSub.Self := FClass.CreateObject();
//Function execution
FSub.Invoke();
//Display result
If FSub.IsResult Then
System.Diagnostics.Debug.WriteLine(FSub.ResultValue);
End If;
End Sub;
On executing the example, the repository assembly with the specified identifier will be loaded to the execution environment. The access to the specified class function will be obtained in the assembly. The function will be executed and result of its work will be displayed to the development environment console.
See also: