public void CollectionToAbstractConfigurationNodeXmlSerializer_Test() { var configuration = new ConfigurationCollection <ExampleConfigurationCollection>(new ConfigurationValueCollection()); var fs = new PhysicalFileSystem(); var temp = Path.GetTempPath(); var pfs = fs.GetOrCreateSubFileSystem(fs.ConvertPathFromInternal(temp)); string test = Path.GetRandomFileName(); var dir = new FS.Directory(test, pfs, pfs.GetDirectoryEntry("/")); dir.OpenDirectory("program") .OpenFile("RMGE01.wbfs").OpenStream().Close(); configuration.Configuration.ExampleConfiguration.FullscreenResolution = FullscreenResolution.Resolution1152X648; var context = new ConfigurationTraversalContext(("game", dir)); var list = context.TraverseCollection(configuration); IAbstractConfigurationNode dolphinList = list["#dolphin"]; var xmlSerializer = new SimpleXmlConfigurationSerializer("Config"); string outputXml = xmlSerializer.Visit(dolphinList); XDocument doc = XDocument.Parse(outputXml); Assert.NotEmpty(doc.Nodes()); }
public override string Transform(IAbstractConfigurationNode node) { IConfigurationSerializationContext <string> context = new StringSerializationContext(); this.SerializeHeader(context); this.SerializeNode(node, context); this.SerializeFooter(context); return(context.Result); }
public void CollectionToAbstractConfigurationNodeCemuXmlSerializer_Test() { var configuration = new ConfigurationCollection <CemuConfigurationCollection>(new ConfigurationValueCollection()); var fs = new PhysicalFileSystem(); var temp = Path.GetTempPath(); var pfs = fs.GetOrCreateSubFileSystem(fs.ConvertPathFromInternal(temp)); string test = Path.GetRandomFileName(); var dir = new FS.Directory(test, pfs, pfs.GetDirectoryEntry("/")); var context = new ConfigurationTraversalContext(("game", dir)); var list = context.TraverseCollection(configuration); IAbstractConfigurationNode dolphinList = list["#cemu"]; var xmlSerializer = new SimpleXmlConfigurationSerializer("content"); string outputXml = xmlSerializer.Visit(dolphinList); XDocument doc = XDocument.Parse(outputXml); Assert.NotEmpty(doc.Nodes()); }
public void CollectionToAbstractConfigurationNodeJsonSerializer_Test() { var configuration = new ConfigurationCollection <ExampleConfigurationCollection>(new ConfigurationValueCollection()); var fs = new PhysicalFileSystem(); var temp = Path.GetTempPath(); var pfs = fs.GetOrCreateSubFileSystem(fs.ConvertPathFromInternal(temp)); var dir = new FS.Directory("test", pfs, pfs.GetDirectoryEntry("/")); configuration.Configuration.ExampleConfiguration.FullscreenResolution = FullscreenResolution.Resolution1152X648; var context = new ConfigurationTraversalContext(("game", dir)); var list = context.TraverseCollection(configuration.Configuration); IAbstractConfigurationNode dolphinList = list["#dolphin"]; var jsonSerializer = new SimpleJsonConfigurationSerializer(); string outputJson = jsonSerializer.Transform(dolphinList); var jtoken = JToken.Parse(outputJson); Assert.True(jtoken.HasValues); }
public void FlattenVisitor_Test() { var configuration = new ConfigurationCollection <ExampleConfigurationCollection>(new ConfigurationValueCollection()); var fs = new PhysicalFileSystem(); var temp = Path.GetTempPath(); var test = Path.GetRandomFileName(); var pfs = fs.GetOrCreateSubFileSystem(fs.ConvertPathFromInternal(temp)); var dir = new FS.Directory(test, pfs, pfs.GetDirectoryEntry("/")); dir.OpenDirectory("program") .OpenFile("RMGE01.wbfs").OpenStream().Close(); configuration.Configuration.ExampleConfiguration.FullscreenResolution = FullscreenResolution.Resolution1152X648; var context = new ConfigurationTraversalContext(("game", dir)); var list = context.TraverseCollection(configuration); IAbstractConfigurationNode dolphinList = list["#dolphin"]; var flattenedList = new FlatteningVisitor().Visit(dolphinList); Assert.Equal(16, ((ListConfigurationNode)flattenedList).Value.Length); }
/// <summary> /// Serialize a <see cref="IAbstractConfigurationNode"/> with the given context. /// </summary> /// <param name="node">The node to serialize.</param> /// <param name="context">The serialization context.</param> /// <param name="index">The position or index of the given node within the current block in the context.</param> public void SerializeNode(IAbstractConfigurationNode node, IConfigurationSerializationContext <T> context, int index = 0) { switch (node) { case ListConfigurationNode listNode: this.SerializeNode(listNode, context, index); break; case StringConfigurationNode stringNode: this.SerializeNode(stringNode, context, index); break; case BooleanConfigurationNode boolNode: this.SerializeNode(boolNode, context, index); break; case IntegralConfigurationNode intNode: this.SerializeNode(intNode, context, index); break; case DecimalConfigurationNode decNode: this.SerializeNode(decNode, context, index); break; case DeviceCapabilityElementConfigurationNode ctrlNode: this.SerializeNode(ctrlNode, context, index); break; case EnumConfigurationNode enumNode: this.SerializeNode(enumNode, context, index); break; default: break; } }
/// <inheritdoc /> public abstract T Transform(IAbstractConfigurationNode node);