Exemple #1
0
        public bool InitializeFromXML(string strXML, string strXsdFile)
        {
            try
            {
                if (strXsdFile.Length > 0)
                {
                    if (false == ValidateAgainstSchema(strXML, strXsdFile))
                    {
                        // Input-xml didn't match provided schema, more information is held in [ValidationErrors]
                        return(false);
                    }
                }

                Converter = new VehicleConverter();
                using (XmlReader reader = XmlReader.Create(new StringReader(strXML)))
                {
                    if (true == InitializeFromXML(reader))
                    {
                        DBContext           = new DatabaseContext();
                        Converter.DbContext = DBContext;
                        return(ValidatePDs());
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Failed to validate xml against schema: " + ex.Message);
            }

            return(false);
        }
Exemple #2
0
        public bool InitializeFromXMLFile(string strFilename, string strSchemaFilename)
        {
            try
            {
                Converter = new VehicleConverter();
                if (false == ValidateAgainstSchema(strFilename, strSchemaFilename))
                {
                    return(false);
                }
                using (var rdr = new StreamReader(strFilename))
                {
                    using (XmlReader reader = XmlReader.Create(rdr))
                    {
                        if (true == InitializeFromXML(reader))
                        {
                            DBContext           = new DatabaseContext();
                            Converter.DbContext = DBContext;
                            return(ValidatePDs());
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            return(false);
        }