IsHaveClassOrInterface(Name: String): Boolean;
Name. Name of class/interface, which inheritance must be checked.
The IsHaveClassOrInterface method checks and returns whether the current structure is inherited from the specified class/interface.
The method returns the following values:
True. The current structure is inherited from the specified class/interface.
False. The current structure 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
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;
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: