Beispiel #1
0
	    /// <summary>
		/// Constructor to initialise a new loader with a dtd path
		/// </summary>
		/// <param name="dtdLoader">The loader for the dtds (pass through a DtdLoader object using the standard constructor for the default behaviour)</param>
		/// <param name="defClassFactory">The factory for the definition classes</param>
	    protected XmlLoader(DtdLoader dtdLoader, IDefClassFactory defClassFactory)
		{
	        if (dtdLoader == null) throw new ArgumentNullException("dtdLoader");
            if (defClassFactory == null) throw new ArgumentNullException("defClassFactory");
	        _dtdLoader = dtdLoader;
	        _defClassFactory = defClassFactory;
		}
Beispiel #2
0
 /// <summary>
 /// Constructor to initialise a new loader with a dtd path
 /// </summary>
 /// <param name="dtdLoader">The loader for the dtds (pass through a DtdLoader object using the standard constructor for the default behaviour)</param>
 /// <param name="defClassFactory">The factory for the definition classes</param>
 protected XmlLoader(DtdLoader dtdLoader, IDefClassFactory defClassFactory)
 {
     if (dtdLoader == null)
     {
         throw new ArgumentNullException("dtdLoader");
     }
     if (defClassFactory == null)
     {
         throw new ArgumentNullException("defClassFactory");
     }
     _dtdLoader       = dtdLoader;
     _defClassFactory = defClassFactory;
 }
Beispiel #3
0
 public void TestLoadFromResource()
 {
     DtdLoader loader = new DtdLoader();
     string dtd = loader.LoadDtd("class");
     Assert.AreNotEqual(0, dtd.Length);
     Assert.AreNotEqual("#include", dtd.Substring(0, 8));
 }
Beispiel #4
0
 /// <summary>
 /// Constructor to initialise a new loader with a dtd path
 /// </summary>
 /// <param name="dtdLoader">The dtd loader</param>
 /// <param name="defClassFactory">The factory for the definition classes</param>
 public XmlKeyLoader(DtdLoader dtdLoader, IDefClassFactory defClassFactory)
     : base(dtdLoader, defClassFactory)
 {
 }
 /// <summary>
 /// Constructor to create a new list of class definitions from the
 /// string provided, using the dtd path provided
 /// </summary>
 /// <param name="xmlClassDefs">The string containing all the
 /// class definitions. If you are loading these from 
 /// a file, you can use 
 /// <code>new StreamReader("filename.xml").ReadToEnd()</code>
 /// to create a continuous string.</param>
 /// <param name="dtdLoader">The dtd loader</param>
 /// <param name="defClassFactory">The factory for the definition classes</param>
 public XmlClassDefsLoader(string xmlClassDefs, DtdLoader dtdLoader, IDefClassFactory defClassFactory)
     : base(dtdLoader, defClassFactory)
 {
     _xmlClassDefs = xmlClassDefs;
 }
Beispiel #6
0
        /// <summary>
        /// Constructor to initialise a new loader with a dtd path
        /// </summary>
		/// <param name="dtdLoader">The dtd loader</param>
		/// <param name="defClassFactory">The factory for the definition classes</param>
        public XmlUILoader(DtdLoader dtdLoader, IDefClassFactory defClassFactory)
			: base(dtdLoader, defClassFactory)
        {
        }
        /// <summary>
        /// Constructor to initialise a new loader with a dtd path
        /// </summary>
		/// <param name="dtdLoader">The dtd loader</param>
		/// <param name="defClassFactory">The factory for the definition classes</param>
        protected XmlLookupListLoader(DtdLoader dtdLoader, IDefClassFactory defClassFactory)
			: base(dtdLoader, defClassFactory)
        {
        }
 /// <summary>
 /// Constructor to initialise a new loader with a dtd path
 /// </summary>
 /// <param name="dtdLoader">The dtd loader</param>
 /// <param name="defClassFactory">The factory for the definition classes</param>
 protected XmlLookupListLoader(DtdLoader dtdLoader, IDefClassFactory defClassFactory)
     : base(dtdLoader, defClassFactory)
 {
 }
 /// <summary>
 /// Constructor to initialise a loader with a dtd path
 /// </summary>
 /// <param name="dtdLoader">The dtd loader</param>
 /// <param name="defClassFactory">The factory for the definition classes</param>
 public XmlSimpleLookupListLoader(DtdLoader dtdLoader, IDefClassFactory defClassFactory)
     : base(dtdLoader, defClassFactory)
 {
     _displayValueDictionary = new Dictionary <string, string>();
 }
Beispiel #10
0
        public void TestSimpleDtd()
        {
            var textFileLoader = Substitute.For<ITextFileLoader>();

            textFileLoader.LoadTextFile("class.dtd").Returns(info => new StringReader(dtd1));

            var loader = new DtdLoader(textFileLoader, "");

            String dtdFileContents = loader.LoadDtd("class");
            Assert.AreEqual(dtd1 + Environment.NewLine, dtdFileContents);
        }
Beispiel #11
0
        public void TestIncludeDtdTwice()
        {
            var textFileLoader = Substitute.For<ITextFileLoader>();
            var loader = new DtdLoader(textFileLoader, "");

            textFileLoader.LoadTextFile("key.dtd").Returns(info => new StringReader(dtd3));
            textFileLoader.LoadTextFile("class.dtd").Returns(info => new StringReader(dtd1));
            textFileLoader.LoadTextFile("property.dtd").Returns(info => new StringReader(dtd2));

            String dtdFileContents = loader.LoadDtd("key");
            Assert.AreEqual(dtd3processed + Environment.NewLine, dtdFileContents);
        }
        /// <summary>
        /// Constructor to initialise a loader with a dtd path
        /// </summary>
		/// <param name="dtdLoader">The dtd loader</param>
		/// <param name="defClassFactory">The factory for the definition classes</param>
        public XmlSimpleLookupListLoader(DtdLoader dtdLoader, IDefClassFactory defClassFactory)
			: base(dtdLoader, defClassFactory)
        {
            _displayValueDictionary = new Dictionary<string, string>();
        }
 /// <summary>
 /// Constructor to initialise a new loader with a dtd path
 /// </summary>
 /// <param name="dtdLoader">The dtd loader</param>
 /// <param name="defClassFactory">The factory for the definition classes</param>
 public XmlUIGridColumnLoader(DtdLoader dtdLoader, IDefClassFactory defClassFactory)
     : base(dtdLoader, defClassFactory)
 {
 }
Beispiel #14
0
        /// <summary>
        /// Loads the lookup list data into the specified property definition
        /// </summary>
        /// <param name="sourceElement">The source element</param>
        /// <param name="def">The property definition to load into</param>
        /// <param name="dtdLoader">The dtd loader</param>
        /// <param name="defClassFactory">The factory for the definition classes</param>
        public static void LoadLookupListIntoProperty(string sourceElement, IPropDef def, DtdLoader dtdLoader, IDefClassFactory defClassFactory)
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(sourceElement);
            if (doc.DocumentElement == null)
            {
                throw new HabaneroDeveloperException
                          ("There was a problem loading the class definitions pleaser refer to the system administrator",
                          "The load lookup list property could not be loaded since the source element does not contain a document name");
            }
            string loaderClassName = "Xml" + doc.DocumentElement.Name + "Loader";
            Type   loaderType      = Type.GetType
                                         (typeof(XmlLookupListLoader).Namespace + "." + loaderClassName, true, true);
            XmlLookupListLoader loader =
                (XmlLookupListLoader)
                Activator.CreateInstance(loaderType, new object[] { dtdLoader, defClassFactory });

            def.LookupList = loader.LoadLookupList(doc.DocumentElement);
        }
Beispiel #15
0
 public void TestDtdNotFoundExceptionWithEmptyPath()
 {
     //---------------Set up test pack-------------------
     DtdLoader loader = new DtdLoader(new TextFileLoader(), "");
     //---------------Execute Test ----------------------
     try
     {
         string dtd = loader.LoadDtd("notexists");
         Assert.Fail("Expected to throw an FileNotFoundException");
     }
         //---------------Test Result -----------------------
     catch (FileNotFoundException ex)
     {
         StringAssert.Contains("The Document Type Definition (DTD) for the XML element 'notexists' was not found in the application's output/execution directory", ex.Message);
     }
 }
Beispiel #16
0
        public void TestMethod()
        {
            //---------------Set up test pack-------------------
            DtdLoader loader = new DtdLoader();
            string dtd = loader.LoadDtd("ui");

            //---------------Assert PreConditions---------------            
            //---------------Execute Test ----------------------
            //---------------Test Result -----------------------
            //---------------Tear Down -------------------------          
        }
        /// <summary>
        /// Constructor to initialise a new loader with a dtd path
        /// </summary>
		/// <param name="dtdLoader">The dtd loader</param>
		/// <param name="defClassFactory">The factory for the definition classes</param>
        public XmlPropertyLoader(DtdLoader dtdLoader, IDefClassFactory defClassFactory)
			: base(dtdLoader, defClassFactory)
        {
        }
Beispiel #18
0
 /// <summary>
 /// Constructor to initialise a new loader with a dtd path
 /// </summary>
 /// <param name="dtdLoader">The dtd loader</param>
 /// <param name="defClassFactory">The factory for the definition classes</param>
 public XmlUIFormFieldLoader(DtdLoader dtdLoader, IDefClassFactory defClassFactory)
     : base(dtdLoader, defClassFactory)
 {
 }
 /// <summary>
 /// Constructor to initialise a new loader with a dtd path
 /// </summary>
 /// <param name="dtdLoader">The dtd loader</param>
 /// <param name="defClassFactory">The factory for the definition classes</param>
 public XmlBusinessObjectLookupListLoader(DtdLoader dtdLoader, IDefClassFactory defClassFactory)
     : base(dtdLoader, defClassFactory)
 {
 }
 /// <summary>
 /// Constructor to initialise a loader with a dtd path
 /// </summary>
 /// <param name="dtdLoader">The dtd loader</param>
 /// <param name="defClassFactory">The factory for the definition classes</param>
 public XmlDatabaseLookupListLoader(DtdLoader dtdLoader, IDefClassFactory defClassFactory)
     : base(dtdLoader, defClassFactory)
 {
 }
Beispiel #21
0
 /// <summary>
 /// Constructor to create a new list of class definitions from the
 /// string provided, using the dtd path provided
 /// </summary>
 /// <param name="xmlClassDefs">The string containing all the
 /// class definitions. If you are loading these from
 /// a file, you can use
 /// <code>new StreamReader("filename.xml").ReadToEnd()</code>
 /// to create a continuous string.</param>
 /// <param name="dtdLoader">The dtd loader</param>
 public XmlClassDefsLoader(string xmlClassDefs, DtdLoader dtdLoader) : this(xmlClassDefs, dtdLoader, new DefClassFactory())
 {
 }
        /// <summary>
        /// Loads the lookup list data into the specified property definition
        /// </summary>
        /// <param name="sourceElement">The source element</param>
        /// <param name="def">The property definition to load into</param>
        /// <param name="dtdLoader">The dtd loader</param>
		/// <param name="defClassFactory">The factory for the definition classes</param>
        public static void LoadLookupListIntoProperty(string sourceElement, IPropDef def, DtdLoader dtdLoader, IDefClassFactory defClassFactory)
        {
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(sourceElement);
            if (doc.DocumentElement == null)
            {
                throw new HabaneroDeveloperException
                    ("There was a problem loading the class definitions pleaser refer to the system administrator",
                     "The load lookup list property could not be loaded since the source element does not contain a document name");
            }
            string loaderClassName = "Xml" + doc.DocumentElement.Name + "Loader";
            Type loaderType = Type.GetType
                (typeof (XmlLookupListLoader).Namespace + "." + loaderClassName, true, true);
            XmlLookupListLoader loader =
                (XmlLookupListLoader)
                Activator.CreateInstance(loaderType, new object[] {dtdLoader, defClassFactory});
            def.LookupList = loader.LoadLookupList(doc.DocumentElement);
        }
Beispiel #23
0
 /// <summary>
 /// Constructor to create a new list of class definitions from the
 /// string provided, using the dtd path provided
 /// </summary>
 /// <param name="xmlClassDefs">The string containing all the
 /// class definitions. If you are loading these from
 /// a file, you can use
 /// <code>new StreamReader("filename.xml").ReadToEnd()</code>
 /// to create a continuous string.</param>
 /// <param name="dtdLoader">The dtd loader</param>
 /// <param name="defClassFactory">The factory for the definition classes</param>
 public XmlClassDefsLoader(string xmlClassDefs, DtdLoader dtdLoader, IDefClassFactory defClassFactory)
     : base(dtdLoader, defClassFactory)
 {
     _xmlClassDefs = xmlClassDefs;
 }
 /// <summary>
 /// Constructor to create a new list of class definitions from the
 /// string provided, using the dtd path provided
 /// </summary>
 /// <param name="xmlClassDefs">The string containing all the
 /// class definitions. If you are loading these from 
 /// a file, you can use 
 /// <code>new StreamReader("filename.xml").ReadToEnd()</code>
 /// to create a continuous string.</param>
 /// <param name="dtdLoader">The dtd loader</param>
 public XmlClassDefsLoader(string xmlClassDefs, DtdLoader dtdLoader) : this(xmlClassDefs, dtdLoader, new DefClassFactory())
 {
 }
Beispiel #25
0
 /// <summary>
 /// Constructor to initialise a new loader with a dtd path
 /// </summary>
 /// <param name="dtdLoader">The dtd loader</param>
 /// <param name="defClassFactory">The factory for the definition classes</param>
 /// <param name="className">The name of the class that has this relationship</param>
 public XmlRelationshipLoader(DtdLoader dtdLoader, IDefClassFactory defClassFactory, string className)
     : base(dtdLoader, defClassFactory)
 {
     _className = className;
 }
        /// <summary>
        /// Constructor to initialise a new loader with a dtd path
        /// </summary>
		/// <param name="dtdLoader">The dtd loader</param>
		/// <param name="defClassFactory">The factory for the definition classes</param>
        public XmlUIGridColumnLoader(DtdLoader dtdLoader, IDefClassFactory defClassFactory)
			: base(dtdLoader, defClassFactory)
        {
        }
        /// <summary>
        /// Constructor to initialise a loader with a dtd path
        /// </summary>
		/// <param name="dtdLoader">The dtd loader</param>
		/// <param name="defClassFactory">The factory for the definition classes</param>
        public XmlDatabaseLookupListLoader(DtdLoader dtdLoader, IDefClassFactory defClassFactory)
			: base(dtdLoader, defClassFactory)
        {
        }
Beispiel #28
0
        public void TestIncludeDtdTwice()
        {
            Mock mockControl = new DynamicMock(typeof (ITextFileLoader));
            ITextFileLoader textFileLoader = (ITextFileLoader) mockControl.MockInstance;

            DtdLoader loader = new DtdLoader(textFileLoader, "");

            mockControl.ExpectAndReturn("LoadTextFile", new StringReader(dtd3), new object[] {"key.dtd"});
            mockControl.ExpectAndReturn("LoadTextFile", new StringReader(dtd1), new object[] { "class.dtd" });
            mockControl.ExpectAndReturn("LoadTextFile", new StringReader(dtd2), new object[] { "property.dtd" });
            mockControl.ExpectAndReturn("LoadTextFile", new StringReader(dtd1), new object[] { "class.dtd" });

            String dtdFileContents = loader.LoadDtd("key");
            Assert.AreEqual(dtd3processed + Environment.NewLine, dtdFileContents);
        }
        /// <summary>
        /// Constructor to initialise a new loader with a dtd path
        /// </summary>
		/// <param name="dtdLoader">The dtd loader</param>
		/// <param name="defClassFactory">The factory for the definition classes</param>
        public XmlBusinessObjectLookupListLoader(DtdLoader dtdLoader, IDefClassFactory defClassFactory)
			: base(dtdLoader, defClassFactory)
        {
        }
Beispiel #30
0
 public void TestDtdNodeInvalidException()
 {
     //---------------Set up test pack-------------------
     DtdLoader loader = new DtdLoader();
     //---------------Execute Test ----------------------
     try
     {
         string dtd = loader.LoadDtd("notexists");
         Assert.Fail("Expected to throw an InvalidXmlDefinitionException");
     }
         //---------------Test Result -----------------------
     catch (InvalidXmlDefinitionException ex)
     {
         StringAssert.Contains("An invalid node 'notexists' was encountered when loading the class definitions", ex.Message);
     }
 }
 /// <summary>
 /// Constructor to initialise a new loader with a dtd path
 /// </summary>
 /// <param name="dtdLoader">The dtd loader</param>
 /// <param name="defClassFactory">The factory for the definition classes</param>
 /// <param name="className">The name of the class that has this relationship</param>
 public XmlRelationshipLoader(DtdLoader dtdLoader, IDefClassFactory defClassFactory, string className)
     : base(dtdLoader, defClassFactory)
 {
     _className = className;
 }
Beispiel #32
0
 public void TestDtdNotFoundExceptionWithIncludesList()
 {
     //---------------Set up test pack-------------------
     DtdLoader loader = new DtdLoader(new TextFileLoader(), "somepath");
     //---------------Execute Test ----------------------
     try
     {
         string dtd = loader.LoadDtd("somefile", new ArrayList());
         Assert.Fail("Expected to throw an FileNotFoundException");
     }
         //---------------Test Result -----------------------
     catch (FileNotFoundException ex)
     {
         StringAssert.Contains("The Document Type Definition (DTD) file, 'somefile', was not found", ex.Message);
     }
 }
Beispiel #33
0
 /// <summary>
 /// Constructor to initialise a new loader with a dtd path
 /// </summary>
 /// <param name="dtdLoader">The dtd loader</param>
 /// <param name="defClassFactory">The factory for the definition classes</param>
 public XmlSuperClassLoader(DtdLoader dtdLoader, IDefClassFactory defClassFactory)
     : base(dtdLoader, defClassFactory)
 {
 }
Beispiel #34
0
        public void TestSimpleDtd()
        {
            Mock mockControl = new DynamicMock(typeof (ITextFileLoader));
            ITextFileLoader textFileLoader = (ITextFileLoader) mockControl.MockInstance;

            DtdLoader loader = new DtdLoader(textFileLoader, "");

            mockControl.ExpectAndReturn("LoadTextFile", new StringReader(dtd1), new object[] {"class.dtd"});
            String dtdFileContents = loader.LoadDtd("class");
            Assert.AreEqual(dtd1 + Environment.NewLine, dtdFileContents);
            mockControl.Verify();
        }
        /// <summary>
        /// Constructor to initialise a new loader with a dtd path
        /// </summary>
		/// <param name="dtdLoader">The dtd loader</param>
		/// <param name="defClassFactory">The factory for the definition classes</param>
        public XmlPrimaryKeyLoader(DtdLoader dtdLoader, IDefClassFactory defClassFactory)
			: base(dtdLoader, defClassFactory)
        {

        }