|
|
|
Forum Member
      
Group: Forum Members
Last Login: 2010-06-22 11:37:01
Posts: 32,
Visits: 193
|
|
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: 2010-05-15 22:36:10
Posts: 188,
Visits: 451
|
|
| 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
|
|
|
|