Exemple #1
0
        /// <summary>
        /// Reads the atom type mappings from the data file.
        /// </summary>
        /// <returns>a <see cref="IReadOnlyDictionary{TKey, TValue}"/> with atom type mappings. <see langword="null"/>, if some reading error occurred.</returns>
        public IReadOnlyDictionary <string, string> ReadAtomTypeMappings()
        {
            IReadOnlyDictionary <string, string> mappings = null;

            var setting = new XmlReaderSettings
            {
                DtdProcessing   = DtdProcessing.Parse,
                ValidationFlags = XmlSchemaValidationFlags.None
            };
            var handler = new OWLAtomTypeMappingHandler();
            var parser  = XmlReader.Create(input, setting);
            var reader  = new XReader
            {
                Handler = handler
            };

            try
            {
                var doc = XDocument.Load(parser);
                reader.Read(doc);
                mappings = handler.GetAtomTypeMappings();
            }
            catch (IOException exception)
            {
                Trace.TraceError(nameof(IOException) + ": " + exception.Message);
                Debug.WriteLine(exception);
            }
            catch (XmlException saxe)
            {
                Trace.TraceError(nameof(XmlException) + ": " + saxe.Message);
                Debug.WriteLine(saxe);
            }
            return(mappings ?? Dictionaries.Empty <string, string>());
        }
        public void TestStartDocument()
        {
            OWLAtomTypeMappingHandler handler = new OWLAtomTypeMappingHandler();

            // nothing is read, but Vector is initialized
            Assert.IsNotNull(handler);
            Assert.IsNull(handler.GetAtomTypeMappings());
        }
        public void TestGetAtomTypeMappings()
        {
            OWLAtomTypeMappingHandler handler = new OWLAtomTypeMappingHandler();

            // nothing is read
            Assert.IsNotNull(handler);
            Assert.IsNull(handler.GetAtomTypeMappings());
        }
        public void TestOWLAtomTypeMappingHandler()
        {
            OWLAtomTypeMappingHandler handler = new OWLAtomTypeMappingHandler();

            Assert.IsNotNull(handler);
        }