@@ -7,6 +7,7 @@ namespace Desktop.Tasks;
77public class FileSystemTaskRepository : ITaskRepository
88{
99 private const string PersistedTasksFileName = "Tasks.txt" ;
10+ public const string LineElementSeparator = "|" ;
1011
1112 public Task < ResultWithValue > All ( )
1213 {
@@ -23,19 +24,16 @@ public Task<ResultWithValue> All()
2324
2425 private static Task ToTask ( string line )
2526 {
27+ var lineElements = line . Split ( LineElementSeparator ) ;
28+
2629 return new Task (
27- id : Guid . Parse ( SplitBySpaces ( line ) . ElementAt ( 0 ) ) ,
28- name : SplitBySpaces ( line ) . ElementAt ( 1 ) ,
29- description : SplitBySpaces ( line ) . Length > 1
30- ? SplitBySpaces ( line ) . Last ( )
30+ id : Guid . Parse ( lineElements . ElementAt ( 0 ) ) ,
31+ name : lineElements . ElementAt ( 1 ) ,
32+ description : lineElements . Length > 1
33+ ? lineElements . Last ( )
3134 : string . Empty ) ;
3235 }
3336
34- private static string [ ] SplitBySpaces ( string line )
35- {
36- return line . Split ( ' ' ) ;
37- }
38-
3937 public async Task < ResultWithoutValue > Save ( Task task )
4038 {
4139 var existingTasks = await All ( ) ;
@@ -44,7 +42,8 @@ public async Task<ResultWithoutValue> Save(Task task)
4442
4543 await File . AppendAllTextAsync (
4644 PersistedTasksFileName ,
47- $ "{ task . Id } { task . Name } { task . Description } { Environment . NewLine } ") ;
45+ $ "{ task . Id } { LineElementSeparator } { task . Name } { LineElementSeparator } { task . Description } " +
46+ $ "{ Environment . NewLine } ") ;
4847
4948 return ResultWithoutValue . Success ( ) ;
5049 }
0 commit comments