Пример #1
0
        public bool ReadEcuFlashScalings(XDocument xmlDoc, IXmlLineInfo info)
        {
            var scalingQuery = from sc in xmlDoc.XPathSelectElements("/rom/scaling")
                               //where table.Ancestors("table").First().IsEmpty
                               select sc;

            foreach (XElement scaling in scalingQuery)
            {
                try{
                    info = scaling;
                    //skip scalings with no name
                    if (scaling.Attribute("name") == null)
                    {
                        throw new Exception("Error, scaling name is null!");
                    }
                    string scalingname = scaling.Attribute("name").Value.ToString();
                    if (!this.ScalingList.ContainsKey(scalingname))
                    {
                        this.ScalingList.Add(scalingname, ScalingFactory.CreateScaling(scaling));
                    }
                }
                catch (Exception crap)
                {
                    Trace.WriteLine("Error reading scaling in " + filePath + " Line number: " + info.LineNumber);
                    Trace.WriteLine(crap.Message);
                    throw;
                }
            }
            return(true);
        }
Пример #2
0
 public static Scaling NewScalingHandler(XElement xel)
 {
     if (xel.Attribute("storagetype") != null)
     {
         return(ScalingFactory.CreateScaling(xel));
     }
     return(null);
 }
Пример #3
0
        /// <summary>
        /// Load parameters from XML an XML file
        /// </summary>
        public bool ReadXML(string path)
        {
            if (path == null)
            {
                return(false);
            }
            XDocument xmlDoc = XDocument.Load(path, LoadOptions.PreserveWhitespace);
            // ROM table fetches here!
            var tableQuery = from t in xmlDoc.XPathSelectElements("/rom/table")
                             select t;

            foreach (XElement table in tableQuery)
            {
                if (table.Attribute("name") == null)
                {
                    continue;
                }
                string tablename = table.Attribute("name").Value.ToString();
                AddRomTable(TableFactory.CreateTable(table, this));
            }
            // RAM table feteches here!
            var ramtableQuery = from t in xmlDoc.XPathSelectElements("/ram/table")
                                select t;

            foreach (XElement table in ramtableQuery)
            {
                if (table.Attribute("name") == null)
                {
                    continue;
                }
                string tablename = table.Attribute("name").Value.ToString();

                AddRamTable(TableFactory.CreateTable(table, this));
            }
            //Read Scalings
            var scalingQuery = from sc in xmlDoc.XPathSelectElements("/rom/scaling")
                               //where table.Ancestors("table").First().IsEmpty
                               select sc;

            foreach (XElement scaling in scalingQuery)
            {
                //skip scalings with no name
                if (scaling.Attribute("name") == null)
                {
                    continue;
                }
                string scalingname = scaling.Attribute("name").Value.ToString();
                if (!this.ScalingList.ContainsKey(scalingname))
                {
                    this.ScalingList.Add(scalingname, ScalingFactory.CreateScaling(scaling));
                }
            }
            return(true);
        }