public bool Read(XmlReader reader) { if (reader.IsStartElement("Channel")) { //This cannot be converted to an OutputChannel //Channel<T> channel = new Channel<T>(new Guid(reader.GetAttribute("id"))); T channel = new T(); channel.Id = new Guid(reader.GetAttribute("id")); //...Any attributes go here... channel.AllowFrameSkip = bool.Parse(reader.GetAttribute("allowFrameSkip")); channel.Name = reader.GetAttribute("name"); if (reader.ElementsExistWithin("Channel")) // Entity element { if (reader.ElementsExistWithin("Patch")) { // Get the controller references. while (reader.IsStartElement("ControllerReference")) { channel.Patch.Add(new Guid(reader.GetAttribute("controllerId")), int.Parse(reader.GetAttribute("outputIndex"))); reader.Skip(); } reader.ReadEndElement(); // Patch } reader.ReadEndElement(); // Channel this.Channel = channel; } return(true); } return(false); }
protected override void ReadSequenceBody(XmlReader reader, ScriptSequenceBase sequence) { string fileName; // Language Sequence.Language = reader.ReadElementString("Language"); // Source files // Read the source files and their references. sequence.SourceFiles.Clear(); if (reader.ElementsExistWithin("SourceFiles")) // Container element for child entity { string sourcePath = Path.Combine(Sequence.SourceDirectory, Sequence.Name); while ((fileName = reader.GetAttribute("name")) != null) { fileName = Path.Combine(sourcePath, fileName); sequence.SourceFiles.Add(SourceFile.Load(fileName)); reader.ReadStartElement("SourceFile"); } reader.ReadEndElement(); // SourceFiles } // Framework assemblies sequence.FrameworkAssemblies.Clear(); if (reader.ElementsExistWithin("FrameworkAssemblies")) { while ((fileName = reader.GetAttribute("name")) != null) { sequence.FrameworkAssemblies.Add(fileName); reader.ReadStartElement("Assembly"); } reader.ReadEndElement(); // FrameworkAssemblies } // External assemblies sequence.ExternalAssemblies.Clear(); if (reader.ElementsExistWithin("ExternalAssemblies")) { while ((fileName = reader.GetAttribute("name")) != null) { sequence.ExternalAssemblies.Add(fileName); reader.ReadStartElement("Assembly"); } reader.ReadEndElement(); // FrameworkAssemblies } }
public bool Read(string filePath) { using (FileStream stream = new FileStream(filePath, FileMode.Open)) { XmlReaderSettings settings = new XmlReaderSettings(); settings.IgnoreWhitespace = true; using (XmlReader reader = XmlReader.Create(stream, settings)) { try { Program program = new Program(); reader.Read(); // Need to start with this to seed the parser. if (reader.NodeType == XmlNodeType.XmlDeclaration) { reader.Read(); } //...Any attributes go here... program.Name = reader.GetAttribute("name"); if (reader.ElementsExistWithin("Program")) // Entity element //... // Sequences { if (reader.ElementsExistWithin("Sequences")) // Container element for child entity { while (reader.NodeType == XmlNodeType.Element) { program.Add(Vixen.Sys.Sequence.Load(reader.GetAttribute("fileName"))); // Still sitting at the Sequence element, need to pass it. reader.Skip(); } reader.ReadEndElement(); // Sequences } reader.ReadEndElement(); // Program this.Program = program; } return(true); } catch { } return(false); } } }
protected override void ReadBody(XmlReader reader) { // Channels if (reader.ElementsExistWithin("Channels")) // Container element for child entity { ChannelReader <OutputChannel> channelReader = new ChannelReader <OutputChannel>(); while (channelReader.Read(reader)) { InsertChannel(channelReader.Channel); } reader.ReadEndElement(); // Channels } }
public bool Read(XmlReader reader) { if (reader.IsStartElement() && reader.Name == "Fixture") { Fixture fixture = new Fixture(); //...Any attributes go here... fixture.AllowFrameSkip = bool.Parse(reader.GetAttribute("allowFrameSkip")); fixture.Name = reader.GetAttribute("name"); // This needs to hold off until after channels are loaded. string fixtureDefinitionName = reader.GetAttribute("fixtureDefinitionName"); if (reader.ElementsExistWithin("Fixture")) // Entity element // Channels { if (reader.ElementsExistWithin("Channels")) // Container element for child entity { ChannelReader <OutputChannel> channelReader = new ChannelReader <OutputChannel>(); while (channelReader.Read(reader)) { fixture.InsertChannel(channelReader.Channel); } reader.ReadEndElement(); // Channels } // With channels loaded, the fixture template reference can be set. fixture.FixtureDefinitionName = fixtureDefinitionName; reader.ReadEndElement(); // Fixture this.Fixture = fixture; } return(true); } return(false); }
protected override void ReadBody(XmlReader reader) { // This is duplicated from a Sequence, but that's to keep it independent. // Just because that changes doesn't mean this should. // Module data reader.ReadStartElement("ModuleData"); ModuleDataSet.Deserialize(reader.ReadOuterXml()); reader.ReadEndElement(); // ModuleData // Fixtures if (reader.ElementsExistWithin("Fixtures")) // Container element for child entity { FixtureReader fixtureReader = new FixtureReader(); while (fixtureReader.Read(reader)) { InsertFixture(fixtureReader.Fixture); } reader.ReadEndElement(); // Fixtures } }
protected override void ReadBody(XmlReader reader) { // This is duplicated from a Sequence, but that's to keep it independent. // Just because that changes doesn't mean this should. // Module data reader.ReadStartElement("ModuleData"); ModuleDataSet.Deserialize(reader.ReadOuterXml()); reader.ReadEndElement(); // ModuleData // Fixtures if(reader.ElementsExistWithin("Fixtures")) { // Container element for child entity FixtureReader fixtureReader = new FixtureReader(); while(fixtureReader.Read(reader)) { InsertFixture(fixtureReader.Fixture); } reader.ReadEndElement(); // Fixtures } }
protected override void ReadBody(XmlReader reader) { // Channels if(reader.ElementsExistWithin("Channels")) { // Container element for child entity ChannelReader<OutputChannel> channelReader = new ChannelReader<OutputChannel>(); while(channelReader.Read(reader)) { InsertChannel(channelReader.Channel); } reader.ReadEndElement(); // Channels } }