Ejemplo n.º 1
0
        static private int VerbCheck(CheckOptions opts)
        {
            string lFileName = Path.ChangeExtension(opts.XmlFileName, "xml");

            Console.WriteLine("Reading and resolving xml file {0}", lFileName);
            ProcessInclude lResult = ProcessInclude.Factory(opts.XmlFileName, "", "");

            lResult.LoadAdvanced(lFileName);
            return(ProcessSanityChecks(lResult.GetDocument()) ? 0 : 1);
        }
Ejemplo n.º 2
0
        static private int VerbCreate(CreateOptions opts)
        {
            WriteVersion();
            string lHeaderFileName = Path.ChangeExtension(opts.XmlFileName, "h");

            if (opts.HeaderFileName != "")
            {
                lHeaderFileName = opts.HeaderFileName;
            }
            Console.WriteLine("Processing xml file {0}", opts.XmlFileName);
            ProcessInclude lResult = ProcessInclude.Factory(opts.XmlFileName, lHeaderFileName, opts.Prefix);

            lResult.Expand();
            // We restore the original namespace in File
            lResult.SetNamespace();
            XmlDocument lXml             = lResult.GetDocument();
            bool        lSuccess         = ProcessSanityChecks(lXml);
            string      lTempXmlFileName = Path.GetTempFileName();

            File.Delete(lTempXmlFileName);
            if (opts.Debug)
            {
                lTempXmlFileName = opts.XmlFileName;
            }
            lTempXmlFileName = Path.ChangeExtension(lTempXmlFileName, "debug.xml");
            if (opts.Debug)
            {
                Console.WriteLine("Writing debug file to {0}", lTempXmlFileName);
            }
            lXml.Save(lTempXmlFileName);
            Console.WriteLine("Writing header file to {0}", lHeaderFileName);
            File.WriteAllText(lHeaderFileName, lResult.HeaderGenerated);
            string lOutputFileName = Path.ChangeExtension(opts.OutputFile, "knxprod");

            if (opts.OutputFile == "")
            {
                lOutputFileName = Path.ChangeExtension(opts.XmlFileName, "knxprod");
            }
            if (lSuccess)
            {
                string lEtsPath = FindEtsPath(lTempXmlFileName);
                ExportKnxprod(lEtsPath, lTempXmlFileName, lOutputFileName);
            }
            else
            {
                Console.WriteLine("--> Skipping creation of {0} due to check errors! <--", lOutputFileName);
            }
            if (!opts.Debug)
            {
                File.Delete(lTempXmlFileName);
            }
            return(0);
        }