IsHaveClassOrInterface(Name: String): Boolean;
IsHaveClassOrInterface(Name: String): Boolean;
Name. Name of class/interface, which inheritance must be checked.
The IsHaveClassOrInterface method checks and returns whether the current construction is inherited from the specified class/interface.
The method returns the following values:
True. The current construction is inherited from the specified class/interface.
False. The current construction is not inherited from the specified class/interface.
Executing the example requires that the repository contains an assembly with the ASSM_TEST identifier. The ICalculate interface is described in the assembly. Several classes are also implemented in the assembly.
Add a link to the Fore, Metabase system assembly.
Sub UserProc;
Var
ForeService: IForeServices;
Runtime: IForeRuntime;
Assm: IForeAssembly;
FClass: IForeClass;
i, j: Integer;
Begin
ForeService := MetabaseClass.Active As IForeServices;
Runtime := ForeService.GetRuntime;
//Load assembly
Runtime.LoadAssembly("ASSM_TEST");
Assm := Runtime.BindToAssembly("ASSM_TEST");
//Get class information
j := Assm.ClassesCount - 1;
For i := 0 To j Do
FClass := Assm.ClassItem(i);
If FClass.ClassType = ForeClassType.Class_ Then
//Check inheritance from the ICalculate interface
If FClass.IsHaveClassOrInterface("ICalculate") Then
Debug.WriteLine("The " + FClass.Name + " class is inherited from the ICalculate interface");
Else
Debug.WriteLine("The " + FClass.Name + " class is not inherited from the ICalculate interface");
End If;
End If;
End For;
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;
i, j: Integer;
Begin
ForeService := Params.Metabase As IForeServices;
Runtime := ForeService.GetRuntime();
//Load assembly
Runtime.LoadAssembly("ASSM_TEST");
Assm := Runtime.BindToAssembly("ASSM_TEST");
//Get class information
j := Assm.ClassesCount() - 1;
For i := 0 To j Do
FClass := Assm.ClassItem(i);
If FClass.ClassType = ForeClassType.fctClass Then
//Check inheritance from the ICalculate interface
If FClass.IsHaveClassOrInterface("ICalculate") Then
System.Diagnostics.Debug.WriteLine("The " + FClass.Name + " class is inherited from the ICalculate interface");
Else
System.Diagnostics.Debug.WriteLine("The " + FClass.Name + " class is not inherited from the ICalculate interface");
End If;
End If;
End For;
End Sub;
On executing the example, the repository assembly with the specified identifier will be loaded to the execution environment. The information about class inheritance that are implemented in assembly will be displayed to development environment console.
See also: