Beispiel #1
0
        /// <summary>
        /// Deserializes the translation table and the input file. Then it checks the input file for validity.
        /// After that it starts the conversion process.
        /// </summary>
        /// <param name="inputFile">The path to the input file.</param>
        /// <param name="outputFile">The path to the output file.</param>
        /// <param name="strictValidation">A flag which indicates if the GSDML should be checked for correctness.</param>
        private static void StartConversion(string inputFile, string outputFile, bool strictValidation)
        {
            if (strictValidation)
            {
                Util.CheckGsdFileForCorrectness(inputFile);
            }

            // Load the GSD and the translation table XML document.
            GsdDocument = Util.LoadXmlDocument(inputFile);
            var translationTable = Util.LoadTranslationTable();

            if (translationTable.DocumentElement == null)
            {
                throw new XmlException("Could not load a XML file.");
            }

            // Add all conversion rules to a list.
            foreach (XmlNode node in translationTable.DocumentElement.ChildNodes)
            {
                TranslationRules.Add(node);
            }

            // Set FileName property of CAEX-element.
            AmlObject.GetType().GetProperties().FirstOrDefault(p => p.Name.Equals("FileName"))?.SetValue(AmlObject, new FileInfo(outputFile).Name);
            Logger?.Log(LogLevel.Debug, "Added the FileName attribute to the CAEXFile element.");

            Logger?.Log(LogLevel.Info, "Start the Handle function.");
            Handle(GsdDocument.DocumentElement, AmlObject);
            Logger?.Log(LogLevel.Info, "Successfully ended the Handle function.");
        }