|
|
|
Forum Member
      
Group: Forum Members
Last Login: 2011-12-15 02:08:37
Posts: 35,
Visits: 260
|
|
As title; I have many classes , I want to know if one class have association relationship with the class2? If have ,I will do some thing.
thank you!
|
|
|
|
|
Supreme Being
      
Group: Forum Members
Last Login: 2012-01-26 14:59:09
Posts: 242,
Visits: 828
|
|
| You can use this function: public static bool AreClasesAssociated(EcoSpace parEcoSpace, Type parClassSource, Type parClassTarget) { bool result = false; //ITypeSystemService tss = EcoServiceHelper.GetTypeSystemService(EcoSpace); IClass classSource = parEcoSpace.TypeSystem.GetClassByType(parClassSource); // IClass classTarget = EcoSpace.TypeSystem.GetClassByType(parClassTarget); if (classSource != null) { foreach (var sf in classSource.AllStructuralFeatures) { if (sf is IAssociationEnd && (sf as IAssociationEnd).Class_.ObjectType == parClassTarget) { result = true; break; } } } return result; } Usage: bool result = AreClasesAssociated (myEcoSpace, typeof(Person, typeof(Order))); where Person, Order - Eco Classes, myEcospace - an EcoSpace instance for the model containing these classes.
/Efim
|
|
|
|