diff --git a/AudioCuesheetEditor/Model/IO/Import/CuesheetImportfile.cs b/AudioCuesheetEditor/Model/IO/Import/CuesheetImportfile.cs index 47170a0b..fecdfd01 100644 --- a/AudioCuesheetEditor/Model/IO/Import/CuesheetImportfile.cs +++ b/AudioCuesheetEditor/Model/IO/Import/CuesheetImportfile.cs @@ -13,6 +13,8 @@ //You should have received a copy of the GNU General Public License //along with Foobar. If not, see //. +using AudioCuesheetEditor.Model.AudioCuesheet.Import; + namespace AudioCuesheetEditor.Model.IO.Import { public class CuesheetImportfile : IImportfile @@ -23,5 +25,7 @@ public class CuesheetImportfile : IImportfile public IEnumerable? FileContentRecognized { get; set; } /// public Exception? AnalyseException { get; set; } + /// + public ImportCuesheet? AnalysedCuesheet { get; set; } } } diff --git a/AudioCuesheetEditor/Model/IO/Import/IImportfile.cs b/AudioCuesheetEditor/Model/IO/Import/IImportfile.cs index 92959ce5..e0250a0b 100644 --- a/AudioCuesheetEditor/Model/IO/Import/IImportfile.cs +++ b/AudioCuesheetEditor/Model/IO/Import/IImportfile.cs @@ -13,6 +13,8 @@ //You should have received a copy of the GNU General Public License //along with Foobar. If not, see //. +using AudioCuesheetEditor.Model.AudioCuesheet.Import; + namespace AudioCuesheetEditor.Model.IO.Import { public interface IImportfile @@ -20,14 +22,18 @@ public interface IImportfile /// /// File content (each element is a file line) /// - public IEnumerable? FileContent { get; set; } + IEnumerable? FileContent { get; set; } /// /// File content with marking which passages has been reconized by scheme /// - public IEnumerable? FileContentRecognized { get; set; } + IEnumerable? FileContentRecognized { get; set; } /// /// Exception that has been thrown while readinng out the file /// - public Exception? AnalyseException { get; set; } + Exception? AnalyseException { get; set; } + /// + /// The cuesheet which was created during analysing the + /// + ImportCuesheet? AnalysedCuesheet { get; set; } } } diff --git a/AudioCuesheetEditor/Model/IO/Import/TextImportfile.cs b/AudioCuesheetEditor/Model/IO/Import/TextImportfile.cs index 5eaaf07e..5cc243b1 100644 --- a/AudioCuesheetEditor/Model/IO/Import/TextImportfile.cs +++ b/AudioCuesheetEditor/Model/IO/Import/TextImportfile.cs @@ -13,12 +13,7 @@ //You should have received a copy of the GNU General Public License //along with Foobar. If not, see //. -using AudioCuesheetEditor.Model.AudioCuesheet; -using AudioCuesheetEditor.Model.IO.Audio; -using AudioCuesheetEditor.Model.Options; -using AudioCuesheetEditor.Model.Utility; -using System.Reflection; -using System.Text.RegularExpressions; +using AudioCuesheetEditor.Model.AudioCuesheet.Import; namespace AudioCuesheetEditor.Model.IO.Import { @@ -33,5 +28,7 @@ public class TextImportfile : IImportfile public IEnumerable? FileContentRecognized { get; set; } /// public Exception? AnalyseException { get;set; } + /// + public ImportCuesheet? AnalysedCuesheet { get; set; } } } diff --git a/AudioCuesheetEditor/Services/IO/CuesheetImportService.cs b/AudioCuesheetEditor/Services/IO/CuesheetImportService.cs index 2087e346..d6784cca 100644 --- a/AudioCuesheetEditor/Services/IO/CuesheetImportService.cs +++ b/AudioCuesheetEditor/Services/IO/CuesheetImportService.cs @@ -22,14 +22,12 @@ namespace AudioCuesheetEditor.Services.IO { public class CuesheetImportService { - public ImportCuesheet? AnalysedCuesheet { get; private set; } - //TODO: Unit Test - public CuesheetImportfile Analyse(IEnumerable fileContent) + public static CuesheetImportfile Analyse(IEnumerable fileContent) { CuesheetImportfile cuesheetImportfile = new(); try { - AnalysedCuesheet = new ImportCuesheet(); + cuesheetImportfile.AnalysedCuesheet = new(); var cuesheetArtistGroupName = "CuesheetArtist"; var cuesheetTitleGroupName = "CuesheetTitle"; var cuesheetFileNameGroupName = "CuesheetFileName"; @@ -70,7 +68,7 @@ public CuesheetImportfile Analyse(IEnumerable fileContent) if (matchGroup != null) { var artist = matchGroup.Value; - AnalysedCuesheet.Artist = artist; + cuesheetImportfile.AnalysedCuesheet.Artist = artist; } else { @@ -85,7 +83,7 @@ public CuesheetImportfile Analyse(IEnumerable fileContent) if (matchGroup != null) { var title = matchGroup.Value; - AnalysedCuesheet.Title = title; + cuesheetImportfile.AnalysedCuesheet.Title = title; } else { @@ -100,7 +98,7 @@ public CuesheetImportfile Analyse(IEnumerable fileContent) if (matchGroup != null) { var audioFile = matchGroup.Value; - AnalysedCuesheet.Audiofile = audioFile; + cuesheetImportfile.AnalysedCuesheet.Audiofile = audioFile; } else { @@ -115,7 +113,7 @@ public CuesheetImportfile Analyse(IEnumerable fileContent) if (matchGroup != null) { var cdTextfile = matchGroup.Value; - AnalysedCuesheet.CDTextfile = cdTextfile; + cuesheetImportfile.AnalysedCuesheet.CDTextfile = cdTextfile; } else { @@ -130,7 +128,7 @@ public CuesheetImportfile Analyse(IEnumerable fileContent) if (matchGroup != null) { var catalogueNumber = matchGroup.Value; - AnalysedCuesheet.Cataloguenumber = catalogueNumber; + cuesheetImportfile.AnalysedCuesheet.Cataloguenumber = catalogueNumber; } else { @@ -244,7 +242,7 @@ public CuesheetImportfile Analyse(IEnumerable fileContent) } if (track != null) { - AnalysedCuesheet.Tracks.Add(track); + cuesheetImportfile.AnalysedCuesheet.Tracks.Add(track); } else { @@ -284,7 +282,7 @@ public CuesheetImportfile Analyse(IEnumerable fileContent) catch (Exception ex) { cuesheetImportfile.AnalyseException = ex; - AnalysedCuesheet = null; + cuesheetImportfile.AnalysedCuesheet = null; cuesheetImportfile.FileContentRecognized = fileContent; } return cuesheetImportfile; diff --git a/AudioCuesheetEditor/Services/IO/ImportManager.cs b/AudioCuesheetEditor/Services/IO/ImportManager.cs index 93622efd..cf267b90 100644 --- a/AudioCuesheetEditor/Services/IO/ImportManager.cs +++ b/AudioCuesheetEditor/Services/IO/ImportManager.cs @@ -90,23 +90,23 @@ public async Task ImportTextAsync(IEnumerable fileContent) { var options = await _localStorageOptionsProvider.GetOptions(); _sessionStateContainer.TextImportFile = _textImportService.Analyse(options, fileContent); - if (_textImportService.AnalysedCuesheet != null) + if (_sessionStateContainer.TextImportFile.AnalysedCuesheet != null) { var applicationOptions = await _localStorageOptionsProvider.GetOptions(); var importCuesheet = new Cuesheet(); - importCuesheet.Import(_textImportService.AnalysedCuesheet, applicationOptions); + importCuesheet.Import(_sessionStateContainer.TextImportFile.AnalysedCuesheet, applicationOptions); _sessionStateContainer.ImportCuesheet = importCuesheet; } } private async Task ImportCuesheetAsync(IEnumerable fileContent) { - _sessionStateContainer.CuesheetImportFile = _cuesheetImportService.Analyse(fileContent); - if (_cuesheetImportService.AnalysedCuesheet != null) + _sessionStateContainer.CuesheetImportFile = CuesheetImportService.Analyse(fileContent); + if (_sessionStateContainer.CuesheetImportFile.AnalysedCuesheet != null) { var applicationOptions = await _localStorageOptionsProvider.GetOptions(); var importCuesheet = new Cuesheet(); - importCuesheet.Import(_cuesheetImportService.AnalysedCuesheet, applicationOptions); + importCuesheet.Import(_sessionStateContainer.CuesheetImportFile.AnalysedCuesheet, applicationOptions); _sessionStateContainer.ImportCuesheet = importCuesheet; } } diff --git a/AudioCuesheetEditor/Services/IO/TextImportService.cs b/AudioCuesheetEditor/Services/IO/TextImportService.cs index 7ecfbbbe..271bfba9 100644 --- a/AudioCuesheetEditor/Services/IO/TextImportService.cs +++ b/AudioCuesheetEditor/Services/IO/TextImportService.cs @@ -27,7 +27,6 @@ namespace AudioCuesheetEditor.Services.IO { public class TextImportService { - public ImportCuesheet? AnalysedCuesheet { get; private set; } public ImportOptions? ImportOptions { get; private set; } //TODO: Unit Test public TextImportfile Analyse(ImportOptions importOptions, IEnumerable fileContent) @@ -37,7 +36,7 @@ public TextImportfile Analyse(ImportOptions importOptions, IEnumerable { importfile.FileContent = fileContent; ImportOptions = importOptions; - AnalysedCuesheet = new ImportCuesheet(); + importfile.AnalysedCuesheet = new ImportCuesheet(); Boolean cuesheetRecognized = false; List recognizedFileContent = []; foreach (var line in fileContent) @@ -51,7 +50,7 @@ public TextImportfile Analyse(ImportOptions importOptions, IEnumerable //Remove entity names var expression = ImportOptions.TextImportScheme.SchemeCuesheet.Replace(String.Format("{0}.", nameof(Cuesheet)), String.Empty).Replace(String.Format("{0}.", nameof(Track)), String.Empty); var regExCuesheet = new Regex(expression); - recognizedLine = AnalyseLine(line, AnalysedCuesheet, regExCuesheet); + recognizedLine = AnalyseLine(line, importfile.AnalysedCuesheet, regExCuesheet); recognized = recognizedLine != null; cuesheetRecognized = recognizedLine != null; } @@ -63,7 +62,7 @@ public TextImportfile Analyse(ImportOptions importOptions, IEnumerable var track = new ImportTrack(); recognizedLine = AnalyseLine(line, track, regExTracks); recognized = recognizedLine != null; - AnalysedCuesheet.Tracks.Add(track); + importfile.AnalysedCuesheet.Tracks.Add(track); } } recognizedFileContent.Add(recognizedLine); @@ -77,7 +76,7 @@ public TextImportfile Analyse(ImportOptions importOptions, IEnumerable { importfile.FileContentRecognized = fileContent; importfile.AnalyseException = ex; - AnalysedCuesheet = null; + importfile.AnalysedCuesheet = null; } return importfile; }