public Move_EventType GetMove_EventType() { reader.Read(); string unitID = GetString(); int timer = (int)GetInt(); int throttle = GetInt(); VectorType location = GetVectorType(); Move_EventType mEvent = new Move_EventType(unitID, timer); mEvent.Location = location; mEvent.Throttle = throttle; reader.ReadEndElement(); return(mEvent); }
public Move_EventType GetMove_EventType() { reader.Read(); string unitID = GetString(); int timer= (int)GetInt(); int throttle = GetInt(); VectorType location = GetVectorType(); Move_EventType mEvent = new Move_EventType(unitID, timer); mEvent.Location=location; mEvent.Throttle=throttle; reader.ReadEndElement(); return mEvent; }
public ScenarioToQueues(string scenarioFile) { TimerQueueClass timerQueue = new TimerQueueClass(); // Extract fields from the XML file (and schema) // see http://weblogs.asp.net/dbrowning/articles/114561.aspx // paths to xml/xsd // const string path = @"C:\Documents and Settings\dgeller\My Documents\Visual Studio 2005\Projects\"; //const string scenarioFile = path + @"DDD\Scenario.xml"; // const string xsdPath = path + @"XMLTrial\XMLTrial\ScenarioSchema.xsd"; FileStream fs; Boolean returnVal; try { returnVal = ValidateSchema(scenarioFile); } catch (ApplicationException e) { Console.WriteLine("Could not validate scenario file " + scenarioFile + " against schema"); if (e.Message != null) { Console.WriteLine(e.Message); } else { Console.WriteLine("No further information available. Sorry."); } return; } if (!returnVal) { return; } try { fs = File.Open(scenarioFile, FileMode.Open); } catch { ApplicationException e = new ApplicationException("Could not open scenario file."); throw e; } reader = new XmlTextReader(fs); parser = new Parser(reader); reader.Read(); // opens, gets to xml declaration reader.Read(); if ("Scenario" == reader.Name) // only Scenario can be top level { reader.Read(); // pass by "Scenario" while (!reader.EOF && !((XmlNodeType.EndElement == reader.NodeType) && ("Scenario" == reader.Name))) { Console.WriteLine("."); switch (reader.NodeType) { case XmlNodeType.Element: Console.WriteLine("ELEMENT <{0}>", reader.Name); switch (reader.Name) { case "Create_Event": Create_EventType createEvent = parser.GetCreate_EventType(); TimerQueueClass.Add(createEvent.Timer, createEvent); Console.WriteLine(" createEvent "); break; case "Move_Event": Move_EventType moveEvent = parser.GetMove_EventType(); TimerQueueClass.Add(moveEvent.Timer, moveEvent); Console.WriteLine(" moveEvent "); break; case "Completion_Event": HappeningCompletionType completionType = parser.GetHappeningCompletionType(); HappeningList.Add(completionType); break; default: Console.WriteLine(" Unknown Element is *{0}* ", reader.Name); break; } break; case XmlNodeType.Text: Console.WriteLine("TEXT <{0}>", reader.Value); break; case XmlNodeType.CDATA: Console.WriteLine("CDATA <![CDATA[{0}]]>", reader.Value); break; case XmlNodeType.ProcessingInstruction: Console.WriteLine("PROC INS<?{0} {1}?>", reader.Name, reader.Value); break; case XmlNodeType.Comment: Console.WriteLine("COMMENT <!--{0}-->", reader.Value); break; case XmlNodeType.XmlDeclaration: Console.WriteLine("<?xml version='1.0'?>"); break; case XmlNodeType.Document: break; case XmlNodeType.DocumentType: Console.WriteLine("DOCTYPE <!DOCTYPE {0} [{1}]", reader.Name, reader.Value); break; case XmlNodeType.EntityReference: Console.WriteLine(reader.Name); break; case XmlNodeType.EndElement: Console.WriteLine("END ELEMENT </{0}>", reader.Name); break; } } } Console.WriteLine("Done\n"); }