예제 #1
0
 private static void CreateReverseRelationshipDefs(ClassDefCol classDefCol, IClassDef classDef)
 {
     foreach (var relationship in classDef.RelationshipDefCol)
     {
         CreateReverseRelationship(classDefCol, classDef, relationship);
     }
 }
예제 #2
0
        public void SetFixtureUp()
        {
            BORegistry.DataAccessor = GetDataAccessorInMemory();
            ClassDefCol classDefCol = typeof(FakeBO).MapClasses();

            ClassDef.ClassDefs.Add(classDefCol);
        }
예제 #3
0
        public void TestLoadClassDefs_WithParameterLessConstructor_ShouldLoadTwoClasses()
        {
            const string     classDefsXml = @"
					<classes>
						<class name=""TestClass"" assembly=""Habanero.Test.BO.Loaders"" >
							<property  name=""TestClassID"" type=""Guid"" />
                            <primaryKey>
                                <prop name=""TestClassID""/>
                            </primaryKey>
						</class>
						<class name=""TestRelatedClass"" assembly=""Habanero.Test.BO.Loaders"" >
							<property  name=""TestRelatedClassID"" type=""Guid"" />
                            <primaryKey>
                                <prop name=""TestRelatedClassID""/>
                            </primaryKey>
						</class>
					</classes>
			"            ;
            IClassDefsLoader loader       = new XmlClassDefsLoader(classDefsXml, new DtdLoader(), GetDefClassFactory());
            ClassDefCol      classDefList =
                loader.LoadClassDefs();

            Assert.AreEqual(2, classDefList.Count);
            Assert.IsTrue(classDefList.Contains("Habanero.Test.BO.Loaders", "TestClass"), "Class 'TestClass' should have been loaded.");
            Assert.IsTrue(classDefList.Contains("Habanero.Test.BO.Loaders", "TestRelatedClass"), "Class 'TestRelatedClass' should have been loaded.");
        }
예제 #4
0
        private static IClassDef GetRelatedObjectClassDef(ClassDefCol classDefs, IRelationshipDef relationshipDef)
        {
            IClassDef relatedObjectClassDef;

            try
            {
                relatedObjectClassDef =
                    classDefs[relationshipDef.RelatedObjectAssemblyName, relationshipDef.RelatedObjectClassNameWithTypeParameter];
            }
            catch (HabaneroDeveloperException)
            {
                try
                {
                    relatedObjectClassDef =
                        ClassDef.ClassDefs[relationshipDef.RelatedObjectAssemblyName, relationshipDef.RelatedObjectClassNameWithTypeParameter];
                }
                catch (HabaneroDeveloperException ex)
                {
                    throw new InvalidXmlDefinitionException
                              (string.Format
                                  ("The relationship '{0}' could not be loaded because when trying to retrieve its related class the folllowing error was thrown '{1}'",
                                  relationshipDef.RelationshipName, ex.Message), ex);
                }
            }
            return(relatedObjectClassDef);
        }
예제 #5
0
        public void Test_GetPrimaryKeyDef_ClassWithPKFromSuperClass()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            IClassDef parentDef = new XmlClassLoader(new DtdLoader(), new DefClassFactory()).LoadClass(
                @"	<class name=""TestClass"" assembly=""Habanero.Test.BO.Loaders"" >
							<property  name=""TestClassID"" type=""Guid"" />
                            <primaryKey>
                                <prop name=""TestClassID""/>
                            </primaryKey>
						</class>"                        );
            IClassDef def = new XmlClassLoader(new DtdLoader(), new DefClassFactory()).LoadClass(
                @"
				<class name=""TestRelatedClass"" assembly=""Habanero.Test.BO.Loaders"">
					<superClass class=""TestClass"" assembly=""Habanero.Test.BO.Loaders"" />
					<property  name=""TestProp"" type=""Guid"" />                    
				</class>
			"            );
            ClassDefCol classDefCol = new ClassDefCol();

            classDefCol.Add(parentDef);
            //---------------Assert Precondition----------------
            Assert.IsNotNull(parentDef.PrimaryKeyDef);
            Assert.IsNotNull(def.SuperClassDef);
            Assert.IsNull(def.PrimaryKeyDef);
            //---------------Execute Test ----------------------
            IPrimaryKeyDef primaryKeyDef = ClassDefHelper.GetPrimaryKeyDef(def, classDefCol);

            //---------------Test Result -----------------------
            Assert.IsNotNull(primaryKeyDef);
            Assert.AreSame(parentDef.PrimaryKeyDef, primaryKeyDef);
        }
예제 #6
0
        public void Test_Validate_PrimaryKey_IsObjectID_True_NonGuidProp()
        {
            //-------------Setup Test Pack ------------------
            const string xml =
                @"
				<classes>
					<class name=""TestClass"" assembly=""Habanero.Test.BO.Loaders"" >
						<property name=""TestClassID""/>
						<primaryKey isObjectID=""true"">
							<prop name=""TestClassID""/>
						</primaryKey>
					</class>
				</classes>
			"            ;
            XmlClassDefsLoader loader       = CreateXmlClassDefsLoader();
            ClassDefCol        classDefList = loader.LoadClassDefs(xml);
            ClassDefValidator  validator    = new ClassDefValidator(GetDefClassFactory());

            //-------------Execute test ---------------------
            try
            {
                validator.ValidateClassDefs(classDefList);
                //---------------Test Result -----------------------
                Assert.Fail("Should have thrown an InvalidXmlDefinitionException");
            }
            catch (InvalidXmlDefinitionException ex)
            {
                Assert.AreEqual(
                    "In the class called 'TestClass', the primary key is set as IsObjectID but the property 'TestClassID' " +
                    "defined as part of the ObjectID primary key is not a Guid.", ex.Message);
            }
        }
예제 #7
0
        public void Test_Force_PrimaryKey_IsObjectID_AsCompulsoryWriteOnce_WithReadWriteRule_WriteNew()
        {
            //-------------Setup Test Pack ------------------
            const string xml =
                @"
				<classes>
					<class name=""TestClass"" assembly=""Habanero.Test.BO.Loaders"" >
						<property name=""TestClassID"" type=""Guid"" readWriteRule=""WriteNew""/>
						<primaryKey isObjectID=""true"">
							<prop name=""TestClassID""/>
						</primaryKey>
					</class>
				</classes>
			"            ;
            XmlClassDefsLoader loader       = CreateXmlClassDefsLoader();
            ClassDefCol        classDefList = loader.LoadClassDefs(xml);
            ClassDefValidator  validator    = new ClassDefValidator(GetDefClassFactory());
            IClassDef          classDef     = classDefList["Habanero.Test.BO.Loaders", "TestClass"];
            IPropDef           keyPropDef   = classDef.PrimaryKeyDef[0];

            //---------------Assert PreConditions---------------
            Assert.IsFalse(keyPropDef.Compulsory);
            Assert.AreEqual(PropReadWriteRule.WriteNew, keyPropDef.ReadWriteRule);
            //-------------Execute test ---------------------
            validator.ValidateClassDefs(classDefList);
            //---------------Test Result -----------------------
            Assert.IsTrue(keyPropDef.Compulsory);
            Assert.AreEqual(PropReadWriteRule.WriteNew, keyPropDef.ReadWriteRule);
        }
예제 #8
0
        public void Test_Force_PrimaryKey_IsObjectID_False_AsCompulsoryWriteOnce_WithReadWriteRule_ReadWrite()
        {
            //-------------Setup Test Pack ------------------
            const string       xml    = @"
				<classes>
					<class name=""TestClass"" assembly=""Habanero.Test.BO.Loaders"" >
						<property name=""TestClassID"" type=""string"" readWriteRule=""ReadWrite""/>
                        <primaryKey isObjectID=""false"">
                            <prop name=""TestClassID""/>
                        </primaryKey>
					</class>
				</classes>
			"            ;
            XmlClassDefsLoader loader = CreateXmlClassDefsLoader();
            //-------------Execute test ---------------------
            ClassDefCol classDefs = loader.LoadClassDefs(xml);

            //---------------Test Result -----------------------
            Assert.AreEqual(1, classDefs.Count);
            Assert.IsTrue(classDefs.Contains("Habanero.Test.BO.Loaders", "TestClass"), "Class 'TestClass' should have been loaded.");
            IClassDef classDef = classDefs["Habanero.Test.BO.Loaders", "TestClass"];

            Assert.AreEqual(1, classDef.PrimaryKeyDef.Count);
            IPropDef keyPropDef = classDef.PrimaryKeyDef[0];

            Assert.IsFalse(keyPropDef.Compulsory);
            Assert.AreEqual(PropReadWriteRule.ReadWrite, keyPropDef.ReadWriteRule);
        }
예제 #9
0
 /// <summary>
 /// Loads the class definition data from the reader
 /// </summary>
 protected override void LoadFromReader()
 {
     _classDefList = _defClassFactory.CreateClassDefCol();
     //_classDefList = new ArrayList();
     _reader.Read();
     _reader.Read();
     do
     {
         try
         {
             XmlClassLoader classLoader = new XmlClassLoader(DtdLoader, _defClassFactory);
             var            classDefCol = classLoader.LoadClass(_reader.ReadOuterXml());
             if (classDefCol != null)
             {
                 _classDefList.Add(classDefCol);
             }
         }
         catch (Exception ex)
         {
             //This is a RecordingExceptionNotifiere so it will log this error and
             // allow the continued processing of this XMLFile.
             GlobalRegistry.UIExceptionNotifier.Notify(ex, "", "Error ");
         }
     } while (_reader.Name == "class");
 }
예제 #10
0
        public void Test_Valid_Relationship_ShouldSetOwningClassDef()
        {
            //----------------------Test Setup ----------------------
            const string       classDefsString = @"
					<classes>

						<class name=""TestRelatedClass"" assembly=""Habanero.Test.BO.Loaders"" >
							<property  name=""TestRelatedClassID"" type=""Guid"" />
							<property  name=""TestClassID"" type=""Guid"" />
                            <primaryKey isObjectID=""false"">
                                <prop name=""TestRelatedClassID""/>
                                <prop name=""TestClassID""/>
                            </primaryKey>
					        <relationship name=""TestClass"" type=""single"" relatedClass=""TestClass"" relatedAssembly=""Habanero.Test.BO.Loaders"" 
                                            owningBOHasForeignKey=""true"" >
						        <relatedProperty property=""TestClassID"" relatedProperty=""TestClassID"" />
					        </relationship>
						</class>
						<class name=""TestClass"" assembly=""Habanero.Test.BO.Loaders"" >
							<property  name=""TestClassID"" type=""Guid"" />
                            <primaryKey>
                                <prop name=""TestClassID""/>
                            </primaryKey>
						</class>
					</classes>
			"            ;
            XmlClassDefsLoader loader          = CreateXmlClassDefsLoader();
            //--------------------Execute Test-------------------------
            ClassDefCol classDefList = loader.LoadClassDefs(classDefsString);
            //---------------Test Result -----------------------
            IClassDef        reverseClassDef = classDefList.FindByClassName("TestRelatedClass");
            IRelationshipDef reverseRelDef   = reverseClassDef.RelationshipDefCol["TestClass"];

            Assert.AreSame(reverseClassDef, reverseRelDef.OwningClassDef);
        }
예제 #11
0
        public void TestLoadClassDefs()
        {
            IClassDefsLoader loader       = CreateXmlClassDefsLoader();
            ClassDefCol      classDefList =
                loader.LoadClassDefs(
                    @"
					<classes>
						<class name=""TestClass"" assembly=""Habanero.Test.BO.Loaders"" >
							<property  name=""TestClassID"" type=""Guid"" />
                            <primaryKey>
                                <prop name=""TestClassID""/>
                            </primaryKey>
						</class>
						<class name=""TestRelatedClass"" assembly=""Habanero.Test.BO.Loaders"" >
							<property  name=""TestRelatedClassID"" type=""Guid"" />
                            <primaryKey>
                                <prop name=""TestRelatedClassID""/>
                            </primaryKey>
						</class>
					</classes>
			"            );

            Assert.AreEqual(2, classDefList.Count);
            Assert.IsTrue(classDefList.Contains("Habanero.Test.BO.Loaders", "TestClass"), "Class 'TestClass' should have been loaded.");
            Assert.IsTrue(classDefList.Contains("Habanero.Test.BO.Loaders", "TestRelatedClass"), "Class 'TestRelatedClass' should have been loaded.");
        }
        public void Test_CreateRevRelationship_WhenIsOneToOne_ShouldCreateSingleRevRel()
        {
            //---------------Set up test pack-------------------
            var singleRelationshipDef = new FakeSingleRelationshipDef();

            singleRelationshipDef.SetAsOneToOne();
            IClassDef   cDefWith121 = typeof(FakeBoNoProps).MapClass();
            ClassDefCol classDefCol = new ClassDefCol {
                cDefWith121
            };

            //---------------Assert Precondition----------------
            Assert.IsTrue(singleRelationshipDef.IsOneToOne);
            //---------------Execute Test ----------------------
            IRelationshipDef reverseRelDef = AllClassesAutoMapper.CreateReverseRelationship(classDefCol, cDefWith121, singleRelationshipDef);

            //---------------Test Result -----------------------

            Assert.AreEqual(singleRelationshipDef.ReverseRelationshipName, reverseRelDef.RelationshipName);
            Assert.AreEqual(singleRelationshipDef.RelationshipName, reverseRelDef.ReverseRelationshipName);
            Assert.IsInstanceOf(typeof(SingleRelationshipDef), reverseRelDef);
            Assert.AreEqual(RelationshipType.Association, reverseRelDef.RelationshipType);
            Assert.AreEqual(DeleteParentAction.DoNothing, reverseRelDef.DeleteParentAction);
            Assert.IsTrue(reverseRelDef.OwningBOHasForeignKey);
        }
예제 #13
0
        public void Test_Map_WhenSingleRelationshipToSubClass_WhenIDPropDeclaredInClassDefXml_ShouldSetRelatedPropToNonStandardID_FixBug1355()
        {
            //---------------Set up test pack-------------------


            var superClassDef = SuperClassWithPKFromClassDef.LoadClassDef();//Loaded from XML
            var defCol        = new ClassDefCol {
                superClassDef
            };


            var subClassWithPKFromClassDef = typeof(SubClassWithPKFromClassDef);
            var relatedToSubClassWithPKFromClassDefType = typeof(RelatedToSubClassWithPKFromClassDef);

            var source = new FakeTypeSource(new[] { subClassWithPKFromClassDef, relatedToSubClassWithPKFromClassDefType });

            AllClassesAutoMapper.ClassDefCol = defCol;
            var allClassesAutoMapper = new AllClassesAutoMapper(source);
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var classDefCol = allClassesAutoMapper.Map();
            //---------------Test Result -----------------------
            var relatedToSubClassWithPKFromClassDef = classDefCol.FindByClassName(relatedToSubClassWithPKFromClassDefType.Name);

            Assert.AreEqual(1, relatedToSubClassWithPKFromClassDef.RelationshipDefCol.Count);
            var subClassWithPKFromClassDefRelDef = relatedToSubClassWithPKFromClassDef.RelationshipDefCol["SubClassWithPKFromClassDefSingleRel"];

            Assert.AreEqual(1, subClassWithPKFromClassDefRelDef.RelKeyDef.Count, "Should have a non composite Key");
            var relPropDef = subClassWithPKFromClassDefRelDef.RelKeyDef.FirstOrDefault();

            Assert.AreEqual("SubClassWithPKFromClassDefSingleRelID", relPropDef.OwnerPropertyName);
            Assert.AreEqual("MYPKID", relPropDef.RelatedClassPropName);
        }
        public void Test_Map_WhenNotHasFKPropDefined_AndIsOneToMany_ShouldFKProp()
        {
            //---------------Set up test pack-------------------
            Type           boWith12M          = typeof(FakeBOWithMultipleRel);
            Type           boWithNoDefinedRel = typeof(FakeBOWithNoRelationship);
            FakeTypeSource source             = new FakeTypeSource(
                new[] { boWith12M, boWithNoDefinedRel });

            AllClassesAutoMapper allClassesAutoMapper = new AllClassesAutoMapper(source);

            //---------------Assert Precondition----------------
            Assert.AreEqual(2, source.GetTypes().Count());
            //---------------Execute Test ----------------------
            ClassDefCol classDefCol = allClassesAutoMapper.Map();
            //---------------Test Result -----------------------
            IClassDef cDefWith12M = classDefCol[boWith12M];

            cDefWith12M.RelationshipDefCol.ShouldHaveCount(1);
            IRelationshipDef relationshipDef = cDefWith12M.RelationshipDefCol.First();

            Assert.IsInstanceOf(typeof(MultipleRelationshipDef), relationshipDef);

            IClassDef cDefNoDefinedRel = classDefCol[boWithNoDefinedRel];

            IRelationshipDef reverseRelDef     = cDefNoDefinedRel.RelationshipDefCol[relationshipDef.ReverseRelationshipName];
            IRelPropDef      reverseRelPropDef = reverseRelDef.RelKeyDef.First();

            cDefNoDefinedRel.PropDefcol.ShouldContain(propDef => propDef.PropertyName == reverseRelPropDef.OwnerPropertyName);
        }
        public void Test_Map_WhenNotHasRevRelDefined_AndIsOneToOne_ShouldCreateSingleRevRel()
        {
            //---------------Set up test pack-------------------
            Type           boWith12M          = typeof(FakeBOWithOneToOneRel);
            Type           boWithNoDefinedRel = typeof(FakeBOWithNoRelationship);
            FakeTypeSource source             = new FakeTypeSource(
                new[] { boWith12M, boWithNoDefinedRel });

            AllClassesAutoMapper allClassesAutoMapper = new AllClassesAutoMapper(source);

            //---------------Assert Precondition----------------
            Assert.AreEqual(2, source.GetTypes().Count());
            //---------------Execute Test ----------------------
            ClassDefCol classDefCol = allClassesAutoMapper.Map();
            //---------------Test Result -----------------------
            IClassDef cDefWith12M = classDefCol[boWith12M];

            cDefWith12M.RelationshipDefCol.ShouldHaveCount(1);
            IRelationshipDef relationshipDef = cDefWith12M.RelationshipDefCol.First();

            Assert.IsInstanceOf(typeof(SingleRelationshipDef), relationshipDef);

            IClassDef cDefNoDefinedRel = classDefCol[boWithNoDefinedRel];

            IRelationshipDef reverseRelDef = cDefNoDefinedRel.RelationshipDefCol[relationshipDef.ReverseRelationshipName];

            Assert.AreEqual(relationshipDef.ReverseRelationshipName, reverseRelDef.RelationshipName);
            Assert.AreEqual(relationshipDef.RelationshipName, reverseRelDef.ReverseRelationshipName);
            Assert.IsInstanceOf(typeof(SingleRelationshipDef), reverseRelDef);
            Assert.AreEqual(RelationshipType.Association, reverseRelDef.RelationshipType);
            Assert.AreEqual(DeleteParentAction.DoNothing, reverseRelDef.DeleteParentAction);
            Assert.IsTrue(reverseRelDef.OwningBOHasForeignKey);
        }
예제 #16
0
        public void TestGetsAndSets()
        {
            ClassDefCol col = new ClassDefCol();

            Assert.AreEqual(0, col.Keys.Count);
            Assert.AreEqual(0, col.Values.Count);
        }
예제 #17
0
        ///<summary>
        /// Returns the <see cref="ClassDef"/> for the super class defined in the specified <see cref="SuperClassDef"/>.
        ///</summary>
        ///<param name="superClassDef">The <see cref="SuperClassDef"/> for which to find its Super class <see cref="ClassDef"/>.</param>
        ///<param name="classDefCol">The <see cref="ClassDefCol"/> to use to search for the super class <see cref="ClassDef"/>.</param>
        ///<returns>Returns the <see cref="ClassDef"/> for the super class defined in the specified <see cref="SuperClassDef"/>.</returns>
        ///<exception cref="InvalidXmlDefinitionException"></exception>
        public static ClassDef GetSuperClassClassDef(ISuperClassDef superClassDef, ClassDefCol classDefCol)
        {
            ClassDef superClassClassDef = null;
            string   assemblyName       = superClassDef.AssemblyName;
            string   className          = superClassDef.ClassName;

            if (assemblyName != null && className != null)
            {
                if (!string.IsNullOrEmpty(superClassDef.TypeParameter))
                {
                    className = className + "_" + superClassDef.TypeParameter;
                }
                if (classDefCol.Contains(assemblyName, className))
                {
                    superClassClassDef = (ClassDef)classDefCol[assemblyName, className];
                }
                if (superClassClassDef == null)
                {
                    throw new InvalidXmlDefinitionException(String.Format(
                                                                "The class definition for the super class with the type " +
                                                                "'{0}' was not found. Check that the class definition " +
                                                                "exists or that spelling and capitalisation are correct. " +
                                                                "There are {1} class definitions currently loaded."
                                                                , assemblyName + "." + className, classDefCol.Count));
                }
            }
            return(superClassClassDef);
        }
예제 #18
0
        public void TestNullClassNamespace()
        {
            string nameSpace;

            ClassDefCol.StripOutNameSpace(null, out nameSpace);
            Assert.IsNull(nameSpace);
        }
예제 #19
0
        public void Test_GetSuperClassClassDef_WithTypeParameter()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            ClassDefCol classDefCol = new ClassDefCol();
            ClassDef    classDef1   = new ClassDef("Habanero.Test.BO", "UnknownClass", null, null, null, null, null);

            classDef1.TypeParameter = "TypeParam1";
            classDefCol.Add(classDef1);
            ClassDef classDef2 = new ClassDef("Habanero.Test.BO", "UnknownClass", null, null, null, null, null);

            classDef2.TypeParameter = "TypeParam2";
            classDefCol.Add(classDef2);
            SuperClassDef superClassDef = new SuperClassDef(classDef2.AssemblyName, classDef2.ClassNameExcludingTypeParameter, ORMapping.ClassTableInheritance, null, null);

            superClassDef.TypeParameter = classDef2.TypeParameter;
            //---------------Assert Precondition----------------
            Assert.AreEqual(0, ClassDef.ClassDefs.Count);
            Assert.AreEqual(2, classDefCol.Count);
            //---------------Execute Test ----------------------
            IClassDef def = ClassDefHelper.GetSuperClassClassDef(superClassDef, classDefCol);

            //---------------Test Result -----------------------
            Assert.IsNotNull(def);
            Assert.AreSame(classDef2, def);
        }
예제 #20
0
        public void Test_GetSuperClassClassDef_NotFound()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            ClassDef classDef = new ClassDef("Habanero.Test.BO", "UnknownClass", null, null, null, null, null);

            ClassDef.ClassDefs.Add(classDef);
            SuperClassDef superClassDef = new SuperClassDef(classDef.AssemblyName, classDef.ClassName, ORMapping.ClassTableInheritance, null, null);
            ClassDefCol   classDefCol   = new ClassDefCol();

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            try
            {
                ClassDefHelper.GetSuperClassClassDef(superClassDef, classDefCol);
                //---------------Test Result -----------------------
                Assert.Fail("Expected to throw an InvalidXmlDefinitionException");
            }
            catch (InvalidXmlDefinitionException ex)
            {
                StringAssert.Contains("The class definition for the super class with the type " +
                                      "'Habanero.Test.BO.UnknownClass' was not found. Check that the class definition " +
                                      "exists or that spelling and capitalisation are correct. " +
                                      "There are 0 class definitions currently loaded.", ex.Message);
            }
        }
예제 #21
0
        public void TestFixtureSetup()
        {
            BORegistry.DataAccessor = new DataAccessorInMemory();
            AllClassesAutoMapper.ClassDefCol.Clear();
            ClassDefCol classDefCol = typeof(FakeBO).MapClasses(type => type.Name != "Unmapped");

            ClassDef.ClassDefs.Add(classDefCol);
        }
예제 #22
0
        /// <summary>
        /// As with LoadClassDefs(string), but uses the root element as a
        /// starting reference point.
        /// </summary>
        /// <param name="allClassesElement">The root element</param>
        /// <returns>Returns an IList object containing the definitions</returns>
        public ClassDefCol LoadClassDefs(XmlElement allClassesElement)
        ///// <returns>Returns an IList object containing the definitions</returns>
        //public IList LoadClassDefs(XmlElement allClassesElement)
        {
            ClassDefCol classDefCol = (ClassDefCol)this.Load(allClassesElement);

            return(classDefCol);
        }
예제 #23
0
 ///<summary>
 /// Validates the ClassDefinitions contained in classDefCol
 ///</summary>
 ///<param name="classDefCol"></param>
 public void ValidateClassDefs(ClassDefCol classDefCol)
 {
     UpdateOwningBOHasForeignKey(classDefCol);
     CheckRelationships(classDefCol);
     UpdateKeyDefinitionsWithBoProp(classDefCol);
     UpdatePrimaryKeys(classDefCol);
     //TODO Brett 02 Feb 2010 check valid business object lookup definition i.e. is property valid and is sort direction valid
 }
        public void SetFixtureUp()
        {
            BORegistry.DataAccessor      = GetDataAccessorInMemory();
            GlobalRegistry.LoggerFactory = new HabaneroLoggerFactoryStub();
            ClassDefCol classDefCol = typeof(FakeBO).MapClasses();

            ClassDef.ClassDefs.Add(classDefCol);
        }
예제 #25
0
        ///<summary>
        /// Validates the ClassDefinitions contained in classDefCol
        ///</summary>
        ///<param name="classDefCol"></param>
        public void ValidateClassDefs(ClassDefCol classDefCol)
        {
            UpdateOwningBOHasForeignKey(classDefCol);
            CheckRelationships(classDefCol);
            UpdateKeyDefinitionsWithBoProp(classDefCol);
            UpdatePrimaryKeys(classDefCol);
            //TODO Brett 02 Feb 2010 check valid business object lookup definition i.e. is property valid and is sort direction valid

        }
예제 #26
0
        private void CheckRelationships(ClassDefCol classDefs)
        {
            var loadedFullPropertyLists = new Dictionary <IClassDef, IPropDefCol>();

            foreach (IClassDef classDef in classDefs)
            {
                CheckRelationshipsForAClassDef(loadedFullPropertyLists, classDef, classDefs);
            }
        }
예제 #27
0
        private void UpdateKeyDefinitionsWithBoProp(ClassDefCol col)
        {
            var loadedFullPropertyLists = new Dictionary <IClassDef, IPropDefCol>();

            foreach (var classDef in col)
            {
                UpdateKeyDefinitionsWithBoProp(loadedFullPropertyLists, classDef, col);
            }
        }
        public void SetFixtureUp()
        {
            BOTestFactoryRegistry.Instance = null;

            ClassDef.ClassDefs.Clear();
            AllClassesAutoMapper.ClassDefCol.Clear();
            ClassDefCol classDefCol = typeof(FakeBO).MapClasses();

            ClassDef.ClassDefs.Add(classDefCol);
        }
예제 #29
0
        public void TestFindByClassName_NotFound_EmptyCol()
        {
            //---------------Set up test pack-------------------
            ClassDefCol col = new ClassDefCol();
            //---------------Execute Test ----------------------
            IClassDef foundClass = col.FindByClassName("DoesNotExist");

            //---------------Test Result -----------------------
            Assert.IsNull(foundClass);
        }
예제 #30
0
        public static IEnumerable <IClassDef> GetClassDefs()
        {
            var loadClassDefs = new ClassDefCol();

            AllClassesAutoMapper.ClassDefCol = loadClassDefs;
            var allClassesAutoMapper = new AllClassesAutoMapper(new AssemblyTypeSource(typeof(Car).Assembly));

            allClassesAutoMapper.Map();
            return(loadClassDefs);
        }
        public void SetFixtureUp()
        {
            BORegistry.DataAccessor = new DataAccessorInMemory();
            AllClassesAutoMapper.ClassDefCol.Clear();
            ClassDefCol classDefCol = typeof(FakeBO).MapClasses(type => type.Name != "Unmapped");

            ClassDef.ClassDefs.Add(classDefCol);
            BOTestFactoryRegistry.Instance.ClearAll();/*
                                                       * BOTestFactoryRegistry.Instance.Register<FakeBO2>(typeof(FakeBO2TestFactory));*/
        }
        public void Test_SetClassDefCol_ShouldSet()
        {
            //---------------Set up test pack-------------------
            var classDefCol = new ClassDefCol();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
             AllClassesAutoMapper.ClassDefCol = classDefCol;
            //---------------Test Result -----------------------
             Assert.AreSame(classDefCol, AllClassesAutoMapper.ClassDefCol);
        }
예제 #33
0
 public void CreateDatabase(ClassDefCol classDefCol)
 {
     _statements = new List<string>();
     foreach (ClassDef classDef in classDefCol)
     {
         CreateTable(classDef);
     }
     AddSettingTableIfNeeded(classDefCol);
     foreach (ClassDef classDef in classDefCol)
     {
         CreateRelationships(classDefCol, classDef);
     }
     Apply();
 }
예제 #34
0
 public void Test_GetSuperClassClassDef()
 {
     //---------------Set up test pack-------------------
     ClassDef.ClassDefs.Clear();
     ClassDefCol classDefCol = new ClassDefCol();
     ClassDef classDef = new ClassDef("Habanero.Test.BO", "UnknownClass", null, null, null, null, null);
     classDefCol.Add(classDef);
     SuperClassDef superClassDef = new SuperClassDef(classDef.AssemblyName, classDef.ClassName, ORMapping.ClassTableInheritance, null, null);
     //---------------Assert Precondition----------------
     Assert.AreEqual(0, ClassDef.ClassDefs.Count);
     Assert.AreEqual(1, classDefCol.Count);
     //---------------Execute Test ----------------------
     IClassDef def = ClassDefHelper.GetSuperClassClassDef(superClassDef, classDefCol);
     //---------------Test Result -----------------------
     Assert.IsNotNull(def);
     Assert.AreSame(classDef, def);
 }
예제 #35
0
 private static void UpdateOwningBOHasForeignKey(ClassDefCol classDefCol)
 {
     foreach (IClassDef classDef in classDefCol)
     {
         foreach (IRelationshipDef relationshipDef in classDef.RelationshipDefCol)
         {
             if (relationshipDef is MultipleRelationshipDef)
             {
                 relationshipDef.OwningBOHasForeignKey = true;
             }
             else if (relationshipDef is SingleRelationshipDef && relationshipDef.OwningBOHasForeignKey)
             {
                 relationshipDef.OwningBOHasForeignKey = !OwningClassHasPrimaryKey(relationshipDef, classDef, classDefCol);
                 ((SingleRelationshipDef)relationshipDef).OwningBOHasPrimaryKey = OwningClassHasPrimaryKey(relationshipDef, classDef, classDefCol);
             }
         }
     }
 }
예제 #36
0
 public void TestAddDuplicateException()
 {
     //---------------Set up test pack-------------------
     ClassDef classDef1 = new ClassDef("ass", "class", null, null, null, null, null);
     ClassDef classDef2 = new ClassDef("ass", "class", null, null, null, null, null);
     ClassDefCol col = new ClassDefCol();
     col.Add(classDef1);
     //---------------Execute Test ----------------------
     try
     {
         col.Add(classDef2);
         Assert.Fail("Expected to throw an HabaneroDeveloperException");
     }
         //---------------Test Result -----------------------
     catch (HabaneroDeveloperException ex)
     {
         StringAssert.Contains("A duplicate class element has been encountered", ex.Message);
     }
 }
예제 #37
0
 private void AddSettingTableIfNeeded(ClassDefCol classDefCol)
 {
     foreach (ClassDef classDef in classDefCol)
     {
         if (classDef.TableName.ToUpper() == "SETTING")
         {
             return;
         }
     }
     const string sql = @"
         CREATE TABLE `setting` (
           `SettingName` varchar(50) NOT NULL default '',
           `SettingValue` varchar(1000) NOT NULL default '',
           `StartDate` datetime default NULL,
           `EndDate` datetime default NULL,
           PRIMARY KEY  (`SettingName`)
         )";
     _statements.Add(sql);
 }
예제 #38
0
        public void TestIndexer_NotFound()
        {
            //---------------Set up test pack-------------------
            ClassDefCol col = new ClassDefCol();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            try
            {
                IClassDef classDef = col["ass", "class"];

                Assert.Fail("Expected error when trying to get a classdef that doesn't exist using the indexer");
            }
            catch (HabaneroDeveloperException ex)
            {
                //---------------Test Result -----------------------
                StringAssert.Contains("No ClassDef has been loaded for ", ex.Message);
            }
        }
예제 #39
0
 public void Test_GetSuperClassClassDef_WithTypeParameter()
 {
     //---------------Set up test pack-------------------
     ClassDef.ClassDefs.Clear();
     ClassDefCol classDefCol = new ClassDefCol();
     ClassDef classDef1 = new ClassDef("Habanero.Test.BO", "UnknownClass", null, null, null, null, null);
     classDef1.TypeParameter = "TypeParam1";
     classDefCol.Add(classDef1);
     ClassDef classDef2 = new ClassDef("Habanero.Test.BO", "UnknownClass", null, null, null, null, null);
     classDef2.TypeParameter = "TypeParam2";
     classDefCol.Add(classDef2);
     SuperClassDef superClassDef = new SuperClassDef(classDef2.AssemblyName, classDef2.ClassNameExcludingTypeParameter, ORMapping.ClassTableInheritance, null, null);
     superClassDef.TypeParameter = classDef2.TypeParameter;
     //---------------Assert Precondition----------------
     Assert.AreEqual(0, ClassDef.ClassDefs.Count);
     Assert.AreEqual(2, classDefCol.Count);
     //---------------Execute Test ----------------------
     IClassDef def = ClassDefHelper.GetSuperClassClassDef(superClassDef, classDefCol);
     //---------------Test Result -----------------------
     Assert.IsNotNull(def);
     Assert.AreSame(classDef2, def);
 }
예제 #40
0
        public void TestIndexer_Get()
        {
            //---------------Set up test pack-------------------
            ClassDef classDef = new ClassDef
                (typeof (MockBo), new PrimaryKeyDef(), new PropDefCol(), new KeyDefCol(), new RelationshipDefCol());
            ClassDefCol col = new ClassDefCol();
            col.Add(classDef);
            //---------------Assert Preconditions --------------

            //---------------Execute Test ----------------------
            IClassDef returnedClassDef = col[typeof (MockBo)];
            //---------------Test Result -----------------------
            Assert.AreEqual(classDef, returnedClassDef);
        }
예제 #41
0
 public void Test_Add_WithSameClassDef_IgnoresAdd()
 {
     //---------------Set up test pack-------------------
     ClassDef classDef = new ClassDef
        (typeof(MockBo), new PrimaryKeyDef(), new PropDefCol(), new KeyDefCol(), new RelationshipDefCol());
     ClassDefCol classDefCol = new ClassDefCol();
     classDefCol.Add(classDef);
     //---------------Assert PreConditions---------------   
     Assert.AreEqual(1, classDefCol.Count);
     //---------------Execute Test ----------------------
     classDefCol.Add(classDef);
     //---------------Test Result -----------------------
     Assert.AreEqual(1, classDefCol.Count);
 }
예제 #42
0
 public void TestFindByClassName_NotFound()
 {
     //---------------Set up test pack-------------------
     ClassDefCol col = new ClassDefCol();
     ClassDef classDef1 = new ClassDef("assembly", "class1", null, null, null, null, null);
     ClassDef classDef2 = new ClassDef("assembly", "class2", null, null, null, null, null);
     ClassDef classDef3 = new ClassDef("assembly", "class3", null, null, null, null, null);
     col.Add(classDef1);
     col.Add(classDef2);
     col.Add(classDef3);
     //---------------Execute Test ----------------------
     IClassDef foundClass = col.FindByClassName("DoesNotExist");
     //---------------Test Result -----------------------
     Assert.IsNull(foundClass);
 }
예제 #43
0
 public void TestFindByClassName_NotFound_EmptyCol()
 {
     //---------------Set up test pack-------------------
     ClassDefCol col = new ClassDefCol();
     //---------------Execute Test ----------------------
     IClassDef foundClass = col.FindByClassName("DoesNotExist");
     //---------------Test Result -----------------------
     Assert.IsNull(foundClass);
 }
예제 #44
0
 internal IPropDefCol GetAllClassDefProps
     (IDictionary<IClassDef, IPropDefCol> loadedFullPropertyLists, IClassDef classDef, ClassDefCol col)
 {
     IPropDefCol allProps;
     if (loadedFullPropertyLists.ContainsKey(classDef))
     {
         allProps = loadedFullPropertyLists[classDef];
     }
     else
     {
         allProps = _defClassFactory.CreatePropDefCol();
         IClassDef currentClassDef = classDef;
         while (currentClassDef != null)
         {
             foreach (IPropDef propDef in currentClassDef.PropDefcol)
             {
                 if (allProps.Contains(propDef.PropertyName)) continue;
                 allProps.Add(propDef);
             }
             currentClassDef = GetSuperClassClassDef(currentClassDef, col);
         }
         loadedFullPropertyLists.Add(classDef, allProps);
     }
     return allProps;
 }
예제 #45
0
 private void UpdateKeyDefinitionsWithBoProp
     (IDictionary<IClassDef, IPropDefCol> loadedFullPropertyLists, IClassDef classDef, ClassDefCol col)
 {
     //This method fixes all the references for a particulare class definitions key definition
     // the issue is that the key definition at the beginiing has a reference to a PropDef that is not
     // valid i.e. does not reference the Prop Def for a particular property.
     // This method attempts to find the actual prop def from the class def and associated it with the keydef.
     if (classDef == null) return;
     var allPropsForAClass = GetAllClassDefProps(loadedFullPropertyLists, classDef, col);
     foreach (var keyDef in classDef.KeysCol)
     {
         var propNames = new List<string>();
         foreach (IPropDef propDef in keyDef)
         {
             propNames.Add(propDef.PropertyName);
         }
         keyDef.Clear();
         //Check Key Properties
         foreach (string propName in propNames)
         {
             if (!allPropsForAClass.Contains(propName))
             {
                 throw new InvalidXmlDefinitionException
                     (String.Format
                          ("In a 'prop' element for the '{0}' key of "
                           + "the '{1}' class, the propery '{2}' given in the "
                           + "'name' attribute does not exist for the class or for any of it's superclasses. "
                           + "Either add the property definition or check the spelling and "
                           + "capitalisation of the specified property.", keyDef.KeyName,
                           classDef.ClassName, propName));
             }
             var keyPropDef = allPropsForAClass[propName];
             keyDef.Add(keyPropDef);
         }
     }
 }
예제 #46
0
 private void CheckRelationships(ClassDefCol classDefs)
 {
     var loadedFullPropertyLists = new Dictionary<IClassDef, IPropDefCol>();
     foreach (IClassDef classDef in classDefs)
     {
         CheckRelationshipsForAClassDef(loadedFullPropertyLists, classDef, classDefs);
     }
 }
예제 #47
0
 private static IClassDef GetSuperClassClassDef(IClassDef currentClassDef, ClassDefCol col)
 {
     var superClassDef = currentClassDef.SuperClassDef;
     return superClassDef == null ? null : col[superClassDef.AssemblyName, superClassDef.ClassName];
 }
예제 #48
0
 public void Test_Add_WithDuplicateClassDefs_ShouldNotAddAgain()
 {
     //---------------Set up test pack-------------------
     XmlClassDefsLoader loader = new XmlClassDefsLoader(GetTestClassDefinition(""), new DtdLoader(), new DefClassFactory());
     ClassDefCol classDefCol = new ClassDefCol();
     ClassDefCol classDefs = loader.LoadClassDefs();
     classDefCol.Add(classDefs);
     //---------------Assert PreConditions---------------   
     Assert.AreEqual(2, classDefs.Count);
     Assert.AreEqual(2, classDefCol.Count);
      //---------------Execute Test ----------------------
     classDefCol.Add(classDefs);
      //---------------Test Result -----------------------
     Assert.AreEqual(2, classDefCol.Count);
 }
예제 #49
0
 private static bool OwningClassHasPrimaryKey(IRelationshipDef relationshipDef, IClassDef classDef, ClassDefCol classDefCol)
 {
     //For each Property in the Relationship Key check if it is defined as the primary key for the
     //class if it is then check the other properties else this is not a primaryKey
     var primaryKeyDef = ClassDefHelper.GetPrimaryKeyDef(classDef, classDefCol);
     foreach (var relPropDef in relationshipDef.RelKeyDef)
     {
         var isInKeyDef = false;
         foreach (IPropDef propDef in primaryKeyDef)
         {
             if (propDef.PropertyName != relPropDef.OwnerPropertyName)
             {
                 isInKeyDef = false;
                 break;
             }
             isInKeyDef = true;
         }
         if (!isInKeyDef) return false;
     }
     return true;
 }
예제 #50
0
 private void ValidateRelKeyDef
     (IClassDef classDef, ClassDefCol classDefs, IRelationshipDef relationshipDef, IClassDef relatedObjectClassDef,
      IDictionary<IClassDef, IPropDefCol> loadedFullPropertyLists)
 {
     var allPropsForClassDef = GetAllClassDefProps(loadedFullPropertyLists, classDef, classDefs);
     var allPropsForRelatedClassDef = GetAllClassDefProps
         (loadedFullPropertyLists, relatedObjectClassDef, classDefs);
     // Check Relationship Properties
     foreach (IRelPropDef relPropDef in relationshipDef.RelKeyDef)
     {
         string ownerPropertyName = relPropDef.OwnerPropertyName;
         if (!allPropsForClassDef.Contains(ownerPropertyName))
         {
             throw new InvalidXmlDefinitionException
                 (String.Format
                      ("In a 'relatedProperty' element for the '{0}' relationship of "
                       + "the '{1}' class, the property '{2}' given in the "
                       + "'property' attribute does not exist for the class or for any of it's superclasses. "
                       + "Either add the property definition or check the spelling and "
                       +
                       "capitalisation of the specified property. Check in the ClassDefs.xml file or fix in Firestarter",
                       relationshipDef.RelationshipName, classDef.ClassName, ownerPropertyName));
         }
         string relatedClassPropName = relPropDef.RelatedClassPropName;
         if (!allPropsForRelatedClassDef.Contains(relatedClassPropName))
         {
             throw new InvalidXmlDefinitionException
                 (String.Format
                      ("In a 'relatedProperty' element for the '{0}' relationship of "
                       + "the '{1}' class, the property '{2}' given in the "
                       +
                       "'relatedProperty' attribute does not exist for the Related class '{3}' or for any of it's superclasses. "
                       + "Either add the property definition or check the spelling and "
                       +
                       "capitalisation of the specified property. Check in the ClassDefs.xml file or fix in Firestarter",
                       relationshipDef.RelationshipName, classDef.ClassName, relatedClassPropName,
                       relatedObjectClassDef.ClassNameFull));
         }
     }
 }
예제 #51
0
 private static IClassDef GetRelatedObjectClassDef(ClassDefCol classDefs, IRelationshipDef relationshipDef)
 {
     IClassDef relatedObjectClassDef;
     try
     {
         relatedObjectClassDef =
             classDefs[relationshipDef.RelatedObjectAssemblyName, relationshipDef.RelatedObjectClassNameWithTypeParameter];
     }
     catch (HabaneroDeveloperException)
     {
         try
         {
             relatedObjectClassDef =
                 ClassDef.ClassDefs[relationshipDef.RelatedObjectAssemblyName, relationshipDef.RelatedObjectClassNameWithTypeParameter];
         }
         catch (HabaneroDeveloperException ex)
         {
             throw new InvalidXmlDefinitionException
                 (string.Format
                      ("The relationship '{0}' could not be loaded because when trying to retrieve its related class the folllowing error was thrown '{1}'",
                       relationshipDef.RelationshipName, ex.Message), ex);
         }
     }
     return relatedObjectClassDef;
 }
예제 #52
0
        private void CheckRelationshipsForAClassDef
            (IDictionary<IClassDef, IPropDefCol> loadedFullPropertyLists, IClassDef classDef, ClassDefCol classDefs)
        {
            if (classDef == null) return;

            foreach (var relationshipDef in classDef.RelationshipDefCol)
            {
                var relatedObjectClassDef = GetRelatedObjectClassDef(classDefs, relationshipDef);
                ValidateReverseRelationship(classDef, relationshipDef, relatedObjectClassDef);
                ValidateRelKeyDef(classDef, classDefs, relationshipDef, relatedObjectClassDef, loadedFullPropertyLists);
            }
        }
예제 #53
0
        public void Test_Add_WithNewClassDefs_ShouldAddThem()
        {
            //---------------Set up test pack-------------------
            XmlClassDefsLoader loader1 = new XmlClassDefsLoader(GetTestClassDefinition(""), new DtdLoader(), new DefClassFactory());
            ClassDefCol classDefCol = new ClassDefCol();
            ClassDefCol classDefs1 = loader1.LoadClassDefs();
            classDefCol.Add(classDefs1);

            XmlClassDefsLoader loader2 = new XmlClassDefsLoader(GetTestClassDefinition("Other"), new DtdLoader(), new DefClassFactory());
            ClassDefCol classDefs2 = loader2.LoadClassDefs();
            //---------------Assert PreConditions---------------   
            Assert.AreEqual(2, classDefCol.Count);
            Assert.AreEqual(2, classDefs2.Count);
            //---------------Execute Test ----------------------
            classDefCol.Add(classDefs2);
            //---------------Test Result -----------------------
            Assert.AreEqual(4, classDefCol.Count);
        }
예제 #54
0
 private void UpdateKeyDefinitionsWithBoProp(ClassDefCol col)
 {
     var loadedFullPropertyLists = new Dictionary<IClassDef, IPropDefCol>();
     foreach (var classDef in col)
     {
         UpdateKeyDefinitionsWithBoProp(loadedFullPropertyLists, classDef, col);
     }
 }
예제 #55
0
 public void TestGetsAndSets()
 {
     ClassDefCol col = new ClassDefCol();
     Assert.AreEqual(0, col.Keys.Count);
     Assert.AreEqual(0, col.Values.Count);
 }
예제 #56
0
        public void Test_Remove_WithAssemblyAndClassName()
        {
            //---------------Set up test pack-------------------
            ClassDefCol col = new ClassDefCol();
            string assemblyName = "Assembly1";
            string className = "Class1";
            ClassDef classDef = new ClassDef(assemblyName, className, null, null, null, null, null, null);
            col.Add(classDef);

            //---------------Assert PreConditions---------------    
            Assert.AreEqual(1, col.Count);
            //---------------Execute Test ----------------------
            col.Remove(assemblyName, className);
            //---------------Test Result -----------------------
            Assert.AreEqual(0, col.Count);
            //---------------Tear Down -------------------------          
        }
예제 #57
0
        public void TestRemove()
        {
            ClassDef classDef = new ClassDef(typeof (String), null, null, null, null, null, null);
            ClassDefCol col = new ClassDefCol();

            col.Add(classDef);
            Assert.AreEqual(1, col.Count);
            col.Remove(classDef);
            Assert.AreEqual(0, col.Count);

            col.Add(classDef);
            Assert.AreEqual(1, col.Count);
            col.Remove(typeof (String));
            Assert.AreEqual(0, col.Count);
        }
예제 #58
0
 public void TestFindByClassName_Found()
 {
     //---------------Set up test pack-------------------
     ClassDefCol col = new ClassDefCol();
     ClassDef classDef1 = new ClassDef("assembly", "class1", null, null, null, null, null);
     ClassDef classDef2 = new ClassDef("assembly", "class2", null, null, null, null, null);
     ClassDef classDef3 = new ClassDef("assembly", "class3", null, null, null, null, null);
     col.Add(classDef1);
     col.Add(classDef2);
     col.Add(classDef3);
     //---------------Execute Test ----------------------
     IClassDef foundClass1 = col.FindByClassName("class1");
     IClassDef foundClass2 = col.FindByClassName("class2");
     IClassDef foundClass3 = col.FindByClassName("class3");
     //---------------Test Result -----------------------
     Assert.AreSame(classDef1, foundClass1);
     Assert.AreSame(classDef2, foundClass2);
     Assert.AreSame(classDef3, foundClass3);
 }
예제 #59
0
 /// <summary>
 /// Loads the class definition data from the reader
 /// </summary>
 protected override void LoadFromReader()
 {
     _classDefList = _defClassFactory.CreateClassDefCol();
     //_classDefList = new ArrayList();
     _reader.Read();
     _reader.Read();
     do
     {
         try
         {
             XmlClassLoader classLoader = new XmlClassLoader(DtdLoader, _defClassFactory);
             var classDefCol = classLoader.LoadClass(_reader.ReadOuterXml());
             if(classDefCol != null) _classDefList.Add(classDefCol);
         }
         catch (Exception ex)
         {
             //This is a RecordingExceptionNotifiere so it will log this error and
             // allow the continued processing of this XMLFile.
             GlobalRegistry.UIExceptionNotifier.Notify(ex, "", "Error ");
         }
     } while (_reader.Name == "class");
 }
 /// <summary>
 /// The <see cref="ClassDef"/> for the related object.
 /// </summary>
 private static IClassDef RelatedObjectClassDef(ClassDefCol classDefCol, IRelationshipDef relationshipDef)
 {
     return classDefCol[relationshipDef.RelatedObjectAssemblyName, relationshipDef.RelatedObjectClassNameWithTypeParameter];
    
 }