コード例 #1
0
        private static RelationshipDefCol CreateRelationshipDefCol(IPropDefCol lPropDefCol)
        {
            RelationshipDefCol relDefCol = new RelationshipDefCol();

            //Define Owner Relationships
            RelKeyDef  relKeyDef;
            IPropDef   propDef;
            RelPropDef lRelPropDef;

            relKeyDef   = new RelKeyDef();
            propDef     = lPropDefCol["ContactPersonID"];
            lRelPropDef = new RelPropDef(propDef, "OwnerId");
            relKeyDef.Add(lRelPropDef);

            //RelationshipDef relDef1 = new MultipleRelationshipDef("Owner", typeof(Car),
            //                         relKeyDef, false, "",
            //                         DeleteParentAction.DereferenceRelated);
            RelationshipDef relDef2 = new MultipleRelationshipDef("Cars", typeof(Car),
                                                                  relKeyDef, false, "Engine.EngineNo",
                                                                  DeleteParentAction.DereferenceRelated);

            //relDefCol.Add(relDef1);
            relDefCol.Add(relDef2);
            relKeyDef = new RelKeyDef();
            // propDef = lPropDefCol["ContactPersonID"];
            lRelPropDef = new RelPropDef(propDef, "ContactPersonID");
            relKeyDef.Add(lRelPropDef);
            RelationshipDef relDef3 = new MultipleRelationshipDef("Addresses", typeof(Address),
                                                                  relKeyDef, false, "",
                                                                  DeleteParentAction.DeleteRelated);

            relDefCol.Add(relDef3);

            return(relDefCol);
        }
コード例 #2
0
        public void TestWithUnknownRelatedType()
        {
            //---------------Set up test pack-------------------
            DefClassFactory       defClassFactory = new DefClassFactory();
            XmlRelationshipLoader loader          = new XmlRelationshipLoader(new DtdLoader(), defClassFactory, "TestClass");
            IPropDefCol           propDefs        = defClassFactory.CreatePropDefCol();

            propDefs.Add(defClassFactory.CreatePropDef("TestProp", "System", "String", PropReadWriteRule.ReadWrite, null, null, false, false, 255, null, null, false));

            RelationshipDef relDef =
                (RelationshipDef)loader.LoadRelationship(
                    @"<relationship 
						name=""TestRelationship"" 
						type=""single"" 
						relatedClass=""Habanero.Test.BO.Loaders.NonExistantTestRelatedClass"" 
						relatedAssembly=""Habanero.Test.BO"" 
                    >
						    <relatedProperty property=""TestProp"" relatedProperty=""TestRelatedProp"" />

					</relationship>"                    ,
                    propDefs);

            //---------------Execute Test ----------------------
            try
            {
                Type classType = relDef.RelatedObjectClassType;

                Assert.Fail("Expected to throw an UnknownTypeNameException");
            }
            //---------------Test Result -----------------------
            catch (UnknownTypeNameException ex)
            {
                StringAssert.Contains("Unable to load the related object type while attempting to load a relationship definition", ex.Message);
            }
        }
コード例 #3
0
 private void Initialise()
 {
     _propDefCol = new PropDefCol();
     //PropDefBuilders = new List<PropDefBuilder<T>>();
     _propertiesDefBuilder = new PropertiesDefBuilder <T>(this, PropDefBuilders);
     _relationshipDefCol   = new RelationshipDefCol();
     _primaryKeyDef        = new PrimaryKeyDef();
 }
コード例 #4
0
ファイル: TestPropDefCol.cs プロジェクト: SaberZA/habanero
        public void Clone_DeepClone_ShouldSetClassDef()
        {
            //---------------Set up test pack-------------------
            IClassDef originalClassDef = LoadClassDef();
            //---------------Execute Test ----------------------
            IPropDefCol newPropDefCol = originalClassDef.PropDefcol.Clone(true);

            //---------------Test Result -----------------------
            Assert.AreEqual(newPropDefCol.ClassDef, originalClassDef.PropDefcol.ClassDef);
        }
コード例 #5
0
        public IKeyDef Build(IPropDefCol propDefCol)
        {
            var keyDef = new KeyDef(_keyName);

            foreach (var propName in _propNames)
            {
                var propDef = propDefCol[propName];
                keyDef.Add(propDef);
            }
            return(keyDef);
        }
コード例 #6
0
        private static MockBO GetMockBO(out RelationshipDef mRelationshipDef, out RelKeyDef mRelKeyDef)
        {
            MockBO      _mMockBO    = new MockBO();
            IPropDefCol mPropDefCol = _mMockBO.PropDefCol;

            mRelKeyDef = new RelKeyDef();
            IPropDef   propDef     = mPropDefCol["MockBOProp1"];
            RelPropDef lRelPropDef = new RelPropDef(propDef, "MockBOID");

            mRelKeyDef.Add(lRelPropDef);
            mRelationshipDef = new SingleRelationshipDef("Relation1", typeof(MockBO), mRelKeyDef, false,
                                                         DeleteParentAction.Prevent);
            return(_mMockBO);
        }
コード例 #7
0
ファイル: Address.cs プロジェクト: kevinbosman/habanero
        private static RelationshipDefCol CreateRelationshipDefCol(IPropDefCol lPropDefCol)
        {
            RelationshipDefCol relDefCol = new RelationshipDefCol();

            //Define Relationships
            RelKeyDef relKeyDef = new RelKeyDef();
            IPropDef propDef = lPropDefCol["ContactPersonID"];

            RelPropDef relPropDef = new RelPropDef(propDef, "ContactPersonID");
            relKeyDef.Add(relPropDef);

            RelationshipDef relDef = new SingleRelationshipDef("ContactPerson", typeof(ContactPerson), relKeyDef, false, DeleteParentAction.Prevent);

            relDefCol.Add(relDef);
            
            return relDefCol;
        }
コード例 #8
0
        public void init()
        {
            this.SetupDBConnection();

            mMockBo = new MockBO();
            mPropDefCol = mMockBo.PropDefCol;

            mRelKeyDef = new RelKeyDef();
            IPropDef propDef = mPropDefCol["MockBOProp1"];

            RelPropDef lRelPropDef = new RelPropDef(propDef, "MockBOID");
            mRelKeyDef.Add(lRelPropDef);

            mRelationshipDef = new SingleRelationshipDef
                ("Relation1", typeof (MockBO), mRelKeyDef, false, DeleteParentAction.Prevent);
            //DatabaseConnection.CurrentConnection.ConnectionString = MyDBConnection.GetConnectionString();
        }
コード例 #9
0
        private static RelationshipDefCol CreateRelationshipDefCol(IPropDefCol lPropDefCol)
        {
            RelationshipDefCol relDefCol = new RelationshipDefCol();

            //Define Owner Relationships
            RelKeyDef relKeyDef = new RelKeyDef();
            IPropDef  propDef   = lPropDefCol["OwnerId"];

            RelPropDef lRelPropDef = new RelPropDef(propDef, "ContactPersonID");

            relKeyDef.Add(lRelPropDef);

            RelationshipDef relDef = new SingleRelationshipDef("Owner", typeof(ContactPerson), relKeyDef, false, DeleteParentAction.Prevent);

            relDefCol.Add(relDef);

            //Define Driver Relationships
            relKeyDef = new RelKeyDef();
            propDef   = lPropDefCol["DriverFK1"];

            lRelPropDef = new RelPropDef(propDef, "PK1Prop1");
            relKeyDef.Add(lRelPropDef);

            propDef = lPropDefCol["DriverFK2"];

            lRelPropDef = new RelPropDef(propDef, "PK1Prop2");
            relKeyDef.Add(lRelPropDef);

            relDef = new SingleRelationshipDef("Driver", typeof(ContactPersonCompositeKey), relKeyDef, true, DeleteParentAction.Prevent);

            relDefCol.Add(relDef);

            //Define Engine Relationships
            relKeyDef = new RelKeyDef();
            propDef   = lPropDefCol["CarID"];

            lRelPropDef = new RelPropDef(propDef, "CarID");
            relKeyDef.Add(lRelPropDef);

            relDef = new SingleRelationshipDef("Engine", typeof(Engine), relKeyDef, false, DeleteParentAction.DereferenceRelated)
            {
                OwningBOHasForeignKey = false
            };
            relDefCol.Add(relDef);
            return(relDefCol);
        }
コード例 #10
0
        private static RelationshipDefCol CreateRelationshipDefCol(IPropDefCol lPropDefCol)
        {
            RelationshipDefCol relDefCol = new RelationshipDefCol();

            //Define Relationships
            RelKeyDef relKeyDef = new RelKeyDef();
            IPropDef  propDef   = lPropDefCol["ContactPersonID"];

            RelPropDef relPropDef = new RelPropDef(propDef, "ContactPersonID");

            relKeyDef.Add(relPropDef);

            RelationshipDef relDef = new SingleRelationshipDef("ContactPerson", typeof(ContactPerson), relKeyDef, false, DeleteParentAction.Prevent);

            relDefCol.Add(relDef);

            return(relDefCol);
        }
コード例 #11
0
        public void init()
        {
            this.SetupDBConnection();

            mMockBo     = new MockBO();
            mPropDefCol = mMockBo.PropDefCol;

            mRelKeyDef = new RelKeyDef();
            IPropDef propDef = mPropDefCol["MockBOProp1"];

            RelPropDef lRelPropDef = new RelPropDef(propDef, "MockBOID");

            mRelKeyDef.Add(lRelPropDef);

            mRelationshipDef = new SingleRelationshipDef
                                   ("Relation1", typeof(MockBO), mRelKeyDef, false, DeleteParentAction.Prevent);
            //DatabaseConnection.CurrentConnection.ConnectionString = MyDBConnection.GetConnectionString();
        }
コード例 #12
0
ファイル: Car.cs プロジェクト: kevinbosman/habanero
        private static RelationshipDefCol CreateRelationshipDefCol(IPropDefCol lPropDefCol)
        {
            RelationshipDefCol relDefCol = new RelationshipDefCol();

            //Define Owner Relationships
            RelKeyDef relKeyDef = new RelKeyDef();
            IPropDef propDef = lPropDefCol["OwnerId"];

            RelPropDef lRelPropDef = new RelPropDef(propDef, "ContactPersonID");
            relKeyDef.Add(lRelPropDef);

            RelationshipDef relDef = new SingleRelationshipDef("Owner", typeof(ContactPerson), relKeyDef, false, DeleteParentAction.Prevent);

            relDefCol.Add(relDef);

            //Define Driver Relationships
            relKeyDef = new RelKeyDef();
            propDef = lPropDefCol["DriverFK1"];

            lRelPropDef = new RelPropDef(propDef, "PK1Prop1");
            relKeyDef.Add(lRelPropDef);

            propDef = lPropDefCol["DriverFK2"];

            lRelPropDef = new RelPropDef(propDef, "PK1Prop2");
            relKeyDef.Add(lRelPropDef);

            relDef = new SingleRelationshipDef("Driver", typeof(ContactPersonCompositeKey), relKeyDef, true, DeleteParentAction.Prevent);

            relDefCol.Add(relDef);

            //Define Engine Relationships
            relKeyDef = new RelKeyDef();
            propDef = lPropDefCol["CarID"];

            lRelPropDef = new RelPropDef(propDef, "CarID");
            relKeyDef.Add(lRelPropDef);

            relDef = new SingleRelationshipDef("Engine", typeof(Engine), relKeyDef, false, DeleteParentAction.DereferenceRelated)
                         {OwningBOHasForeignKey = false};
            relDefCol.Add(relDef);
            return relDefCol;
        }
コード例 #13
0
        public void init()
        {
            _mockBo = new MockBO();
            _propDefCol = _mockBo.PropDefCol;

            _RelKeyDef = new RelKeyDef();
            IPropDef propDef = _propDefCol["MockBOID"];

            RelPropDef relPropDef = new RelPropDef(propDef, "MockBOProp1");
            _RelKeyDef.Add(relPropDef);

            _multipleRelationshipDef = new MultipleRelationshipDef("Relation1", typeof(MockBO),
                                                       _RelKeyDef, false, "",
                                                       DeleteParentAction.DeleteRelated);


            _singleRelationshipDef = new SingleRelationshipDef("Single", typeof(MockBO),
                                                       _RelKeyDef, false,
                                                       DeleteParentAction.DeleteRelated);
            DatabaseConnection.CurrentConnection.ConnectionString = MyDBConnection.GetConnectionString();
        }
コード例 #14
0
        public void init()
        {
            BORegistry.DataAccessor = new DataAccessorInMemory();
            _fakeBO = new MockBO();
            _propDefCol = _fakeBO.PropDefCol;

            _RelKeyDef = new RelKeyDef();
            IPropDef propDef = _propDefCol["MockBOID"];

            RelPropDef relPropDef = new RelPropDef(propDef, "MockBOProp1");
            _RelKeyDef.Add(relPropDef);

            _multipleRelationshipDef = new MultipleRelationshipDef("Relation1", typeof(MockBO),
                                                       _RelKeyDef, false, "",
                                                       DeleteParentAction.DeleteRelated);


            _singleRelationshipDef = new SingleRelationshipDef("Single", typeof(MockBO),
                                                       _RelKeyDef, false,
                                                       DeleteParentAction.DeleteRelated);
        }
コード例 #15
0
        public void init()
        {
            _mockBo     = new MockBO();
            _propDefCol = _mockBo.PropDefCol;

            _RelKeyDef = new RelKeyDef();
            IPropDef propDef = _propDefCol["MockBOID"];

            RelPropDef relPropDef = new RelPropDef(propDef, "MockBOProp1");

            _RelKeyDef.Add(relPropDef);

            _multipleRelationshipDef = new MultipleRelationshipDef("Relation1", typeof(MockBO),
                                                                   _RelKeyDef, false, "",
                                                                   DeleteParentAction.DeleteRelated);


            _singleRelationshipDef = new SingleRelationshipDef("Single", typeof(MockBO),
                                                               _RelKeyDef, false,
                                                               DeleteParentAction.DeleteRelated);
            DatabaseConnection.CurrentConnection.ConnectionString = MyDBConnection.GetConnectionString();
        }
コード例 #16
0
        public void Test_LoadInheritedRelationship_UsingInheritedRelatedProps()
        {
            DefClassFactory       defClassFactory = new DefClassFactory();
            XmlRelationshipLoader loader          = new XmlRelationshipLoader(new DtdLoader(), defClassFactory, "TestClass");
            IPropDefCol           propDefs        = defClassFactory.CreatePropDefCol();

            propDefs.Add(defClassFactory.CreatePropDef("TestProp", "System", "String", PropReadWriteRule.ReadWrite, null, null, false, false, 255, null, null, false));

            RelationshipDef relDef =
                (RelationshipDef)loader.LoadRelationship(
                    @"<relationship 
						name=""TestRelationship"" 
						type=""single"" 
						relatedClass=""Habanero.Test.BO.Loaders.NonExistantTestRelatedClass"" 
						relatedAssembly=""Habanero.Test.BO"" 
                    >
						    <relatedProperty property=""TestProp"" relatedProperty=""TestRelatedProp"" />

					</relationship>"                    ,
                    propDefs);
            Type classType = relDef.RelatedObjectClassType;
        }
コード例 #17
0
        public void init()
        {
            BORegistry.DataAccessor = new DataAccessorInMemory();
            _fakeBO     = new MockBO();
            _propDefCol = _fakeBO.PropDefCol;

            _RelKeyDef = new RelKeyDef();
            IPropDef propDef = _propDefCol["MockBOID"];

            RelPropDef relPropDef = new RelPropDef(propDef, "MockBOProp1");

            _RelKeyDef.Add(relPropDef);

            _multipleRelationshipDef = new MultipleRelationshipDef("Relation1", typeof(MockBO),
                                                                   _RelKeyDef, false, "",
                                                                   DeleteParentAction.DeleteRelated);


            _singleRelationshipDef = new SingleRelationshipDef("Single", typeof(MockBO),
                                                               _RelKeyDef, false,
                                                               DeleteParentAction.DeleteRelated);
        }
コード例 #18
0
        public void Test_Map_When2LayersOfInheritance_AndHasDiscriminatorProp_ShouldNotCreateDiscriminator()
        {
            //---------------Set up test pack-------------------
            Type superSuperClass = typeof(FakeBOSuperClassWithDesc);
            Type superClass      = typeof(FakeBOSubClassSuperHasDesc);
            Type subClass        = typeof(FakeBOSubSubClassSuperHasDesc);

            //---------------Assert Precondition----------------
            Assert.AreSame(superClass, subClass.BaseType);
            Assert.AreSame(superSuperClass, superClass.BaseType);
            Assert.IsTrue(superSuperClass.ToTypeWrapper().IsBusinessObject);
            //---------------Execute Test ----------------------
            var inheritanceDef = subClass.MapInheritance();
            //---------------Test Result -----------------------
            var superClassClassDef      = inheritanceDef.SuperClassClassDef;
            var superSuperClassClassDef = superClassClassDef.SuperClassDef.SuperClassClassDef;

            superClassClassDef.PropDefcol.ShouldHaveCount(0,
                                                          "No Properties Should be created for SuperClass since ID and Discriminator will be on SuperSuperClass");
            IPropDefCol superSuperClassProps = superSuperClassClassDef.PropDefcol;

            superSuperClassProps.ShouldHaveCount(2, "Discriminator and ID Prop should be created");
            superSuperClassProps.ShouldContain(def => def.PropertyName == "FakeBOSuperClassWithDescType");
        }
コード例 #19
0
ファイル: XmlKeyLoader.cs プロジェクト: kevinbosman/habanero
 /// <summary>
 /// Loads a key definition from the xml element and property definition
 /// collection provided
 /// </summary>
 /// <param name="keyElement">The xml key definition element</param>
 /// <param name="propDefs">The collection of property definitions</param>
 /// <returns>Returns the key definition</returns>
 public IKeyDef LoadKey(XmlElement keyElement, IPropDefCol propDefs)
 {
     _propDefCol = propDefs;
     return (IKeyDef) Load(keyElement);
 }
コード例 #20
0
ファイル: XmlKeyLoader.cs プロジェクト: kevinbosman/habanero
 /// <summary>
 /// Loads a key definition from the xml string and property definition
 /// collection provided
 /// </summary>
 /// <param name="xmlKeyDef">The xml key definition string</param>
 /// <param name="propDefs">The collection of property definitions</param>
 /// <returns>Returns the key definition</returns>
 public IKeyDef LoadKey(string xmlKeyDef, IPropDefCol propDefs)
 {
     return LoadKey(this.CreateXmlElement(xmlKeyDef), propDefs);
 }
コード例 #21
0
        /// <summary>
        /// Loads all relevant data from the reader
        /// </summary>
        protected override void LoadFromReader()
        {
            try
            {
                _superClassDef = null;
                _relationshipDefCol = _defClassFactory.CreateRelationshipDefCol();
                _keyDefCol = _defClassFactory.CreateKeyDefCol();
                _uiDefCol = _defClassFactory.CreateUIDefCol();
                _propDefCol = _defClassFactory.CreatePropDefCol();
                _reader.Read();
                LoadClassInfo();
                LoadTableName();
                LoadDisplayName();
                LoadTypeParameter();
                LoadClassID();
                LoadModuleName();
                _reader.Read();

                
                
                List<string> keyDefXmls = new List<string>();
                List<string> propDefXmls = new List<string>();
                List<string> relationshipDefXmls = new List<string>();
                List<string> uiDefXmls = new List<string>();
                string superclassDescXML = null;
                string primaryKeDefXML = null;
                while (_reader.Name != "class")
                {
                    switch (_reader.Name)
                    {
                        case "superClass":
                            superclassDescXML = _reader.ReadOuterXml();
                            break;
                        case "property":
                            propDefXmls.Add(_reader.ReadOuterXml());
                            break;
                        case "key":
                            keyDefXmls.Add(_reader.ReadOuterXml());
                            break;
                        case "primaryKey":
                            primaryKeDefXML = _reader.ReadOuterXml();
                            break;
                        case "relationship":
                            relationshipDefXmls.Add(_reader.ReadOuterXml());
                            break;
                        case "ui":
                            uiDefXmls.Add(_reader.ReadOuterXml());
                            break;
                        default:
                            throw new InvalidXmlDefinitionException("The element '" +
                                    _reader.Name + "' is not a recognised class " +
                                    "definition element.  Ensure that you have the correct " +
                                    "spelling and capitalisation, or see the documentation " +
                                    "for available options.");
                    }
                }

                LoadSuperClassDesc(superclassDescXML);
                LoadPropDefs(propDefXmls);
                LoadKeyDefs(keyDefXmls);
                LoadPrimaryKeyDef(primaryKeDefXML);
                _classDef = CreateClassDef();
                LoadRelationshipDefs(relationshipDefXmls);
                _classDef.RelationshipDefCol = _relationshipDefCol;
                LoadUIDefs(uiDefXmls);
                _classDef.UIDefCol = _uiDefCol;
            }
            catch (Exception ex)
            {
                throw new InvalidXmlDefinitionException(string.Format("The Class Definition for {0} - {1} could not be loaded ", _className ,_displayName ), ex);
            }
        }
コード例 #22
0
 protected void Initialise()
 {
     itsLoader   = new XmlPrimaryKeyLoader(new DtdLoader(), GetDefClassFactory());
     itsPropDefs = GetDefClassFactory().CreatePropDefCol();
     itsPropDefs.Add(GetDefClassFactory().CreatePropDef("TestProp", "System", "String", PropReadWriteRule.ReadWrite, null, null, false, false, 255, null, null, false));
 }
コード例 #23
0
 /// <summary>
 /// Loads a relationship definition from the xml string provided
 /// </summary>
 /// <param name="xmlRelationshipDef">The xml string</param>
 /// <param name="propDefs">The property definition collection</param>
 /// <returns>Returns a relationship definition</returns>
 public IRelationshipDef LoadRelationship(string xmlRelationshipDef, IPropDefCol propDefs)
 {
     return LoadRelationship(this.CreateXmlElement(xmlRelationshipDef), propDefs);
 }
コード例 #24
0
		///<summary>
		///</summary>
		///<param name="assemblyName"></param>
		///<param name="className"></param>
		///<param name="displayName"></param>
		///<param name="primaryKeyDef"></param>
		///<param name="propDefCol"></param>
		///<param name="keyDefCol"></param>
		///<param name="relationshipDefCol"></param>
		///<param name="uiDefCol"></param>
		///<returns></returns>
		public IClassDef CreateClassDef(string assemblyName, string className, string displayName, IPrimaryKeyDef primaryKeyDef,
									   IPropDefCol propDefCol, KeyDefCol keyDefCol, IRelationshipDefCol relationshipDefCol,
									   UIDefCol uiDefCol)
		{
			return new ClassDef(assemblyName, className, displayName, primaryKeyDef, propDefCol, keyDefCol, relationshipDefCol, uiDefCol);
		}
コード例 #25
0
 /// <summary>
 /// Loads a primary key definition from the xml element and property
 /// definition collection provided
 /// </summary>
 /// <param name="primaryKeyElement">The xml element</param>
 /// <param name="propDefs">The property definition collection</param>
 /// <returns>Returns the primary key definition</returns>
 internal IPrimaryKeyDef LoadPrimaryKey(XmlElement primaryKeyElement, IPropDefCol propDefs)
 {
     _propDefCol = propDefs;
     return((IPrimaryKeyDef)Load(primaryKeyElement));
 }
コード例 #26
0
        /// <summary>
        /// Loads a relationship definition from the xml element provided
        /// </summary>
        /// <param name="relationshipElement">The xml element</param>
        /// <param name="propDefs">The property definition collection</param>
        /// <returns>Returns a relationship definition</returns>
        public IRelationshipDef LoadRelationship(XmlElement relationshipElement, IPropDefCol propDefs)
        {
//            _propDefCol = propDefs;
            return((IRelationshipDef)this.Load(relationshipElement));
        }
コード例 #27
0
 /// <summary>
 /// Loads a relationship definition from the xml string provided
 /// </summary>
 /// <param name="xmlRelationshipDef">The xml string</param>
 /// <param name="propDefs">The property definition collection</param>
 /// <returns>Returns a relationship definition</returns>
 public IRelationshipDef LoadRelationship(string xmlRelationshipDef, IPropDefCol propDefs)
 {
     return(LoadRelationship(this.CreateXmlElement(xmlRelationshipDef), propDefs));
 }
コード例 #28
0
 protected void Initialise() {
     _xmlKeyLoader = new XmlKeyLoader(new DtdLoader(), GetDefClassFactory());
     _propDefCol = GetDefClassFactory().CreatePropDefCol();
     _propDefCol.Add(GetDefClassFactory().CreatePropDef("TestProp", "System", "String", PropReadWriteRule.ReadWrite, "TestProp", null, false, false, 255, null, null, false));
 }
コード例 #29
0
ファイル: ContactPerson.cs プロジェクト: kevinbosman/habanero
        private static RelationshipDefCol CreateRelationshipDefCol(IPropDefCol lPropDefCol)
        {
            RelationshipDefCol relDefCol = new RelationshipDefCol();

            //Define Owner Relationships
            RelKeyDef relKeyDef;
            IPropDef propDef;
            RelPropDef lRelPropDef;
            
            relKeyDef = new RelKeyDef();
            propDef = lPropDefCol["ContactPersonID"];
            lRelPropDef = new RelPropDef(propDef, "OwnerId");
            relKeyDef.Add(lRelPropDef);

            //RelationshipDef relDef1 = new MultipleRelationshipDef("Owner", typeof(Car),
            //                         relKeyDef, false, "",
            //                         DeleteParentAction.DereferenceRelated);
            RelationshipDef relDef2 = new MultipleRelationshipDef("Cars", typeof(Car),
                         relKeyDef, false, "Engine.EngineNo",
                         DeleteParentAction.DereferenceRelated);
            //relDefCol.Add(relDef1);
            relDefCol.Add(relDef2);
            relKeyDef = new RelKeyDef();
           // propDef = lPropDefCol["ContactPersonID"];
            lRelPropDef = new RelPropDef(propDef, "ContactPersonID");
            relKeyDef.Add(lRelPropDef);
            RelationshipDef relDef3 = new MultipleRelationshipDef("Addresses", typeof(Address),
                                                 relKeyDef, false, "",
                                                 DeleteParentAction.DeleteRelated);
            relDefCol.Add(relDef3);
			
            return relDefCol;
        }
コード例 #30
0
ファイル: TestXmlKeyLoader.cs プロジェクト: SaberZA/habanero
 protected void Initialise()
 {
     _xmlKeyLoader = new XmlKeyLoader(new DtdLoader(), GetDefClassFactory());
     _propDefCol   = GetDefClassFactory().CreatePropDefCol();
     _propDefCol.Add(GetDefClassFactory().CreatePropDef("TestProp", "System", "String", PropReadWriteRule.ReadWrite, "TestProp", null, false, false, 255, null, null, false));
 }
コード例 #31
0
 /// <summary>
 /// Loads a primary key definition from the xml element and property
 /// definition collection provided
 /// </summary>
 /// <param name="primaryKeyElement">The xml element</param>
 /// <param name="propDefs">The property definition collection</param>
 /// <returns>Returns the primary key definition</returns>
 internal IPrimaryKeyDef LoadPrimaryKey(XmlElement primaryKeyElement, IPropDefCol propDefs)
 {
     _propDefCol = propDefs;
     return (IPrimaryKeyDef) Load(primaryKeyElement);
 }
コード例 #32
0
 protected void Initialise()
 {
     _loader   = new XmlRelationshipLoader(new DtdLoader(), GetDefClassFactory(), "TestClass");
     _propDefs = GetDefClassFactory().CreatePropDefCol();
     _propDefs.Add(GetDefClassFactory().CreatePropDef("TestProp", "System", "String", PropReadWriteRule.ReadWrite, null, null, false, false, 255, null, null, false));
 }
コード例 #33
0
        /// <summary>
        /// Loads a relationship definition from the xml element provided
        /// </summary>
        /// <param name="relationshipElement">The xml element</param>
        /// <param name="propDefs">The property definition collection</param>
        /// <returns>Returns a relationship definition</returns>
        public IRelationshipDef LoadRelationship(XmlElement relationshipElement, IPropDefCol propDefs)
        {
//            _propDefCol = propDefs;
            return (IRelationshipDef) this.Load(relationshipElement);
        }
コード例 #34
0
ファイル: XmlKeyLoader.cs プロジェクト: SaberZA/habanero
 /// <summary>
 /// Loads a key definition from the xml string and property definition
 /// collection provided
 /// </summary>
 /// <param name="xmlKeyDef">The xml key definition string</param>
 /// <param name="propDefs">The collection of property definitions</param>
 /// <returns>Returns the key definition</returns>
 public IKeyDef LoadKey(string xmlKeyDef, IPropDefCol propDefs)
 {
     return(LoadKey(this.CreateXmlElement(xmlKeyDef), propDefs));
 }
コード例 #35
0
 /// <summary>
 /// Loads a primary key definition from the xml string and property
 /// definition collection provided
 /// </summary>
 /// <param name="xmlPrimaryKeyDef">The xml string</param>
 /// <param name="propDefs">The property definition collection</param>
 /// <returns>Returns the primary key definition</returns>
 internal IPrimaryKeyDef LoadPrimaryKey(string xmlPrimaryKeyDef, IPropDefCol propDefs)
 {
     return LoadPrimaryKey(this.CreateXmlElement(xmlPrimaryKeyDef), propDefs);
 }
コード例 #36
0
 protected void Initialise() {
     _loader = new XmlRelationshipLoader(new DtdLoader(), GetDefClassFactory(), "TestClass");
     _propDefs = GetDefClassFactory().CreatePropDefCol();
     _propDefs.Add(GetDefClassFactory().CreatePropDef("TestProp", "System", "String", PropReadWriteRule.ReadWrite, null, null, false, false, 255, null, null, false));
 }
コード例 #37
0
 protected void Initialise() {
     itsLoader = new XmlPrimaryKeyLoader(new DtdLoader(), GetDefClassFactory());
     itsPropDefs = GetDefClassFactory().CreatePropDefCol();
     itsPropDefs.Add(GetDefClassFactory().CreatePropDef("TestProp", "System", "String", PropReadWriteRule.ReadWrite, null, null, false, false, 255, null, null, false));
 }
コード例 #38
0
        /// <summary>
        /// Loads all relevant data from the reader
        /// </summary>
        protected override void LoadFromReader()
        {
            try
            {
                _superClassDef      = null;
                _relationshipDefCol = _defClassFactory.CreateRelationshipDefCol();
                _keyDefCol          = _defClassFactory.CreateKeyDefCol();
                _uiDefCol           = _defClassFactory.CreateUIDefCol();
                _propDefCol         = _defClassFactory.CreatePropDefCol();
                _reader.Read();
                LoadClassInfo();
                LoadTableName();
                LoadDisplayName();
                LoadTypeParameter();
                LoadClassID();
                LoadModuleName();
                _reader.Read();



                List <string> keyDefXmls          = new List <string>();
                List <string> propDefXmls         = new List <string>();
                List <string> relationshipDefXmls = new List <string>();
                List <string> uiDefXmls           = new List <string>();
                string        superclassDescXML   = null;
                string        primaryKeDefXML     = null;
                while (_reader.Name != "class")
                {
                    switch (_reader.Name)
                    {
                    case "superClass":
                        superclassDescXML = _reader.ReadOuterXml();
                        break;

                    case "property":
                        propDefXmls.Add(_reader.ReadOuterXml());
                        break;

                    case "key":
                        keyDefXmls.Add(_reader.ReadOuterXml());
                        break;

                    case "primaryKey":
                        primaryKeDefXML = _reader.ReadOuterXml();
                        break;

                    case "relationship":
                        relationshipDefXmls.Add(_reader.ReadOuterXml());
                        break;

                    case "ui":
                        uiDefXmls.Add(_reader.ReadOuterXml());
                        break;

                    default:
                        throw new InvalidXmlDefinitionException("The element '" +
                                                                _reader.Name + "' is not a recognised class " +
                                                                "definition element.  Ensure that you have the correct " +
                                                                "spelling and capitalisation, or see the documentation " +
                                                                "for available options.");
                    }
                }

                LoadSuperClassDesc(superclassDescXML);
                LoadPropDefs(propDefXmls);
                LoadKeyDefs(keyDefXmls);
                LoadPrimaryKeyDef(primaryKeDefXML);
                _classDef = CreateClassDef();
                LoadRelationshipDefs(relationshipDefXmls);
                _classDef.RelationshipDefCol = _relationshipDefCol;
                LoadUIDefs(uiDefXmls);
                _classDef.UIDefCol = _uiDefCol;
            }
            catch (Exception ex)
            {
                throw new InvalidXmlDefinitionException(string.Format("The Class Definition for {0} - {1} could not be loaded ", _className, _displayName), ex);
            }
        }
コード例 #39
0
ファイル: XmlKeyLoader.cs プロジェクト: SaberZA/habanero
 /// <summary>
 /// Loads a key definition from the xml element and property definition
 /// collection provided
 /// </summary>
 /// <param name="keyElement">The xml key definition element</param>
 /// <param name="propDefs">The collection of property definitions</param>
 /// <returns>Returns the key definition</returns>
 public IKeyDef LoadKey(XmlElement keyElement, IPropDefCol propDefs)
 {
     _propDefCol = propDefs;
     return((IKeyDef)Load(keyElement));
 }
コード例 #40
0
 ///<summary>
 ///</summary>
 ///<param name="assemblyName"></param>
 ///<param name="className"></param>
 ///<param name="displayName"></param>
 ///<param name="primaryKeyDef"></param>
 ///<param name="propDefCol"></param>
 ///<param name="keyDefCol"></param>
 ///<param name="relationshipDefCol"></param>
 ///<param name="uiDefCol"></param>
 ///<returns></returns>
 public IClassDef CreateClassDef(string assemblyName, string className, string displayName, IPrimaryKeyDef primaryKeyDef,
                                 IPropDefCol propDefCol, KeyDefCol keyDefCol, IRelationshipDefCol relationshipDefCol,
                                 UIDefCol uiDefCol)
 {
     return(new ClassDef(assemblyName, className, displayName, primaryKeyDef, propDefCol, keyDefCol, relationshipDefCol, uiDefCol));
 }
コード例 #41
0
 /// <summary>
 /// Loads a primary key definition from the xml string and property
 /// definition collection provided
 /// </summary>
 /// <param name="xmlPrimaryKeyDef">The xml string</param>
 /// <param name="propDefs">The property definition collection</param>
 /// <returns>Returns the primary key definition</returns>
 internal IPrimaryKeyDef LoadPrimaryKey(string xmlPrimaryKeyDef, IPropDefCol propDefs)
 {
     return(LoadPrimaryKey(this.CreateXmlElement(xmlPrimaryKeyDef), propDefs));
 }
コード例 #42
0
ファイル: TestClassDef.cs プロジェクト: kevinbosman/habanero
 public void SetPropDefCol(IPropDefCol col)
 {
     PropDefcol = col;
 }