public int Execute(ICommandOption opt) { var option = (CommandOption)opt; using var repository = new LiteDbKeySwitchRepository(option.DatabasePath); var translator = new KeySwitchToVstExpressionMapModel(); var presenter = new IExportingVstExpressionMapPresenter.Null(); var interactor = new ExportingVstExpressionMapInteractor(repository, translator, presenter); var input = new ExportingVstExpressionMapRequest(option.Developer, option.Product, option.Instrument); Console.WriteLine($"Developer=\"{option.Developer}\", Product=\"{option.Product}\", Instrument=\"{option.Instrument}\""); var response = interactor.Execute(input); if (!response.Elements.Any()) { Console.WriteLine("records not found"); return(0); } foreach (var i in response.Elements) { var outputDirectory = option.OutputDirectory; if (option.DirectoryStructure) { outputDirectory = EntityDirectoryHelper.CreateDirectoryTree( i.KeySwitch, new DirectoryPath(outputDirectory) ).Path; } else { PathUtility.CreateDirectory(outputDirectory); } var prefix = $"{i.KeySwitch.ProductName} {i.KeySwitch.InstrumentName}"; var path = $"{prefix}.expressionmap"; path = PathUtility.GenerateFilePathWhenExist(path, outputDirectory, option.OverWrite); Console.Out.WriteLine($"export to {path}"); File.WriteAllText(path, i.XmlText.Value, Encoding.UTF8); } return(0); }
public void ConvertTest() { var articulation = TestDataGenerator.CreateArticulation( new List <MidiNoteOn> { IMidiNoteOnFactory.Default.Create(10, 20) }, new List <MidiControlChange> { }, new List <MidiProgramChange> { } ); var entity = TestDataGenerator.CreateKeySwitch(articulation); var translator = new KeySwitchToVstExpressionMapModel(); var text = translator.Translate(entity); Console.WriteLine(text); }