BindToSub(SubName: String): IForeSub;
BindToSub(SubName: String): Prognoz.Platform.Interop.Fore.IForeSub;
SubName. The procedure/function anme implemented in the assembly global namespace.
The BindToSub method returns information about procedure/function with the specified name.
The method returns Null, if procedure/function with the specified name is not found.
Executing the example requires that the repository contains an assembly with the ASSM_TEST identifier. The Run function is implemented in the global namespace of assembly.
Add a link to the Fore, Metabase system assembly.
Sub UserProc;
Var
ForeService: IForeServices;
Runtime: IForeRuntime;
Assm: IForeAssembly;
FSub: IForeSub;
Begin
ForeService := MetabaseClass.Active As IForeServices;
Runtime := ForeService.GetRuntime;
//Load assembly
Assm := Runtime.BindToAssembly("ASSM_TEST");
//Get function
FSub := Assm.BindToSub("Run");
FSub.Invoke;
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;
FSub: IForeSub;
Begin
ForeService := Params.Metabase As IForeServices;
Runtime := ForeService.GetRuntime();
//Load assembly
Assm := Runtime.BindToAssembly("ASSM_TEST");
//Get function
FSub := Assm.BindToSub("Run");
FSub.Invoke();
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 Run function will be obtained and launched for execution in the assembly. The result of function work will be displayed to the development environment console.
See also: