示例#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;
		}
示例#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;
 }
示例#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));
 }
示例#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;
 }
示例#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)
        {
        }
示例#8
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>
 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>();
 }
示例#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);
        }
示例#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>();
        }
示例#13
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 XmlUIGridColumnLoader(DtdLoader dtdLoader, IDefClassFactory defClassFactory)
     : base(dtdLoader, defClassFactory)
 {
 }
示例#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);
        }
示例#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);
     }
 }
示例#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 -------------------------          
        }
示例#17
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 XmlPropertyLoader(DtdLoader dtdLoader, IDefClassFactory defClassFactory)
			: base(dtdLoader, defClassFactory)
        {
        }
示例#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)
 {
 }
示例#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())
 {
 }
示例#22
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);
        }
示例#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;
 }
示例#24
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())
 {
 }
示例#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;
 }
示例#26
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 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)
        {
        }
示例#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)
        {
        }
示例#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;
 }
示例#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);
     }
 }
示例#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)
 {
 }
示例#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();
        }
示例#35
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 XmlPrimaryKeyLoader(DtdLoader dtdLoader, IDefClassFactory defClassFactory)
			: base(dtdLoader, defClassFactory)
        {

        }