public async override Task CompileConfiguration() { var serializer = new SimpleCfgConfigurationSerializer(); var tokenizer = new ConfigurationTraversalContext(); var node = tokenizer.TraverseCollection(this.ConfigurationProfile); var retroArchNode = node["#retroarch"]; StringBuilder configContents = new StringBuilder(); configContents.Append(serializer.Transform(retroArchNode)); var configFile = this.Scratch.OpenDirectory("config") .OpenFile("retroarch.cfg"); foreach (var port in this.ControllerPorts) { var mappings = this.InputMappings[port.PhysicalDeviceInstance.Driver]; var template = new InputTemplate <RetroPadTemplate>(port.LayoutMapping, port.PortIndex); template.Template.Configuration.InputJoypadIndex = port.PhysicalDeviceInstance.EnumerationIndex; var inputNode = tokenizer.TraverseInputTemplate(template, mappings, port.PortIndex); configContents.Append(serializer.Transform(retroArchNode)); } await configFile.WriteAllTextAsync(configContents.ToString()); }
public void InputTemplateToAbstractConfigurationNodeCfgSerializer_Test() { var mapcol = new ControllerElementMappingProfile("Keyboard", "TEST_CONTROLLER", InputDriver.Keyboard, IDeviceEnumerator.VirtualVendorID, new XInputDeviceInstance(0).DefaultLayout); IDeviceInputMapping mapping = new TestInputMapping(); var input = new InputTemplate <IRetroArchInput>(mapcol).Template; var fs = new PhysicalFileSystem(); var temp = Path.GetTempPath(); var pfs = fs.GetOrCreateSubFileSystem(fs.ConvertPathFromInternal(temp)); var dir = new FS.Directory("test", pfs, pfs.GetDirectoryEntry("/")); var context = new ConfigurationTraversalContext(); var list = context.TraverseInputTemplate(input, mapping, 0); var cfgSerializer = new SimpleCfgConfigurationSerializer(); string outputCfg = cfgSerializer.Transform(list); Assert.NotEqual(string.Empty, outputCfg); // todo: test cfg parse }
public void InputTemplateToAbstractConfigurationNodeCfgSerializer_Test() { var testmappings = new StoneProvider().Controllers["XBOX_CONTROLLER"]; var realmapping = JsonConvert.DeserializeObject <ControllerLayout>( TestUtilities.GetStringResource("InputMappings.xinput_device.json")); var mapcol = ControllerElementMappings.GetDefaultMappings(realmapping, testmappings); string _mapping = TestUtilities.GetStringResource("InputMappings.DirectInput.XINPUT_DEVICE.json"); IInputMapping mapping = JsonConvert.DeserializeObject <InputMapping>(_mapping); var input = new InputTemplate <IRetroArchInput>(mapcol).Template; var fs = new PhysicalFileSystem(); var temp = Path.GetTempPath(); var pfs = fs.GetOrCreateSubFileSystem(fs.ConvertPathFromInternal(temp)); var dir = new FS.Directory("test", pfs, pfs.GetDirectoryEntry("/")); var context = new ConfigurationTraversalContext(); var list = context.TraverseInputTemplate(input, mapping, 0); var cfgSerializer = new SimpleCfgConfigurationSerializer(); string outputCfg = cfgSerializer.Transform(list); Assert.NotEqual(string.Empty, outputCfg); // todo: test cfg parse }
public void CollectionToAbstractConfigurationNodeCfgSerializer_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 cfgSerializer = new SimpleCfgConfigurationSerializer(); string outputCfg = cfgSerializer.Transform(dolphinList); Assert.NotEqual(string.Empty, outputCfg); // todo: test cfg parse }