
How do you to find out what a classes a class is inheriting from
Hi,
I am creating a code generator for my model and I am trying to work out if the current class is inheriting from another class?
Whats the best API call to use?
Cheers
Albert
Answer

Hi Albert,
To find out what classes and class in inheriting, you will need to find the Generalizations for that class, where that class is the target.
There is an method called GetTargetGeneralizations that will allow you to find these.
I have updated the EF Core Generator to support this. See the file DatabaseObject.razor for an example.
Also here is a copy of the relevant code.
public static string GetInheritance(IClassifier umlClass)
{
var generals=umlClass.GetTargetGeneralizations();
if (generals.Any())
{
return ": "+((INamedElement)generals.First().Source).Name;
}
return "";
}
Hope this helps, any more questions please ask me.
Customer support service by UserEcho
Hi Albert,
To find out what classes and class in inheriting, you will need to find the Generalizations for that class, where that class is the target.
There is an method called GetTargetGeneralizations that will allow you to find these.
I have updated the EF Core Generator to support this. See the file DatabaseObject.razor for an example.
Also here is a copy of the relevant code.
public static string GetInheritance(IClassifier umlClass)
{
var generals=umlClass.GetTargetGeneralizations();
if (generals.Any())
{
return ": "+((INamedElement)generals.First().Source).Name;
}
return "";
}
Hope this helps, any more questions please ask me.