﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>CapableObjects Forums / ECO / General discussions  / I want to know if one class have associations with the class which name is class2  in code at run time / Latest Posts</title><generator>InstantForum.NET v4.1.4</generator><description>CapableObjects Forums</description><link>http://www.capableobjects.com/apps/InstantForum414/</link><webMaster>forums@capableobjects.com</webMaster><lastBuildDate>Wed, 08 Feb 2012 22:39:43 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: I want to know if one class have associations with the class which name is class2  in code at run time</title><link>http://www.capableobjects.com/apps/InstantForum414/Topic5032-4-1.aspx</link><description>You can use this function:&lt;/P&gt;&lt;P&gt;        public static bool AreClasesAssociated(EcoSpace parEcoSpace, Type parClassSource, Type parClassTarget)&lt;BR&gt;        {&lt;BR&gt;            bool result = false;&lt;BR&gt;            //ITypeSystemService tss = EcoServiceHelper.GetTypeSystemService(EcoSpace);&lt;BR&gt;            IClass classSource = parEcoSpace.TypeSystem.GetClassByType(parClassSource);&lt;BR&gt;            // IClass classTarget = EcoSpace.TypeSystem.GetClassByType(parClassTarget);&lt;/P&gt;&lt;P&gt;            if (classSource != null)&lt;BR&gt;            {&lt;BR&gt;                foreach (var sf in classSource.AllStructuralFeatures)&lt;BR&gt;                {&lt;BR&gt;                    if (sf is IAssociationEnd &amp;amp;&amp;amp; (sf as IAssociationEnd).Class_.ObjectType == parClassTarget)&lt;BR&gt;                    {&lt;BR&gt;                        result = true;&lt;BR&gt;                        break;&lt;BR&gt;                    }&lt;BR&gt;                }&lt;BR&gt;            }&lt;BR&gt;            return result;&lt;BR&gt;        }&lt;/P&gt;&lt;P&gt;Usage: bool result = AreClasesAssociated (myEcoSpace, typeof(Person, typeof(Order)));&lt;/P&gt;&lt;P&gt;where Person, Order - Eco Classes, myEcospace - an EcoSpace instance for the model containing these classes.</description><pubDate>Mon, 22 Mar 2010 14:25:00 GMT</pubDate><dc:creator>efim</dc:creator></item><item><title>I want to know if one class have associations with the class which name is class2  in code at run time</title><link>http://www.capableobjects.com/apps/InstantForum414/Topic5032-4-1.aspx</link><description>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.&lt;br&gt;thank you!</description><pubDate>Mon, 22 Mar 2010 12:43:34 GMT</pubDate><dc:creator>wangwei.njcn</dc:creator></item></channel></rss>
