@@ -6,6 +6,7 @@ public interface IDownloadedLog
6
6
{
7
7
string ContainerName { get ; }
8
8
9
+ void IterateLines ( Action < string > action ) ;
9
10
void IterateLines ( Action < string > action , params string [ ] thatContain ) ;
10
11
string [ ] GetLinesContaining ( string expectedString ) ;
11
12
string [ ] FindLinesThatContain ( params string [ ] tags ) ;
@@ -25,58 +26,39 @@ internal DownloadedLog(WriteToFileLogHandler logHandler, string containerName)
25
26
26
27
public string ContainerName { get ; }
27
28
28
- public void IterateLines ( Action < string > action , params string [ ] thatContain )
29
+ public void IterateLines ( Action < string > action )
29
30
{
30
31
using var file = File . OpenRead ( logFile . FullFilename ) ;
31
32
using var streamReader = new StreamReader ( file ) ;
32
33
33
34
var line = streamReader . ReadLine ( ) ;
34
35
while ( line != null )
35
36
{
36
- if ( thatContain . All ( line . Contains ) )
37
- {
38
- action ( line ) ;
39
- }
37
+ action ( line ) ;
40
38
line = streamReader . ReadLine ( ) ;
41
39
}
42
40
}
43
41
44
- public string [ ] GetLinesContaining ( string expectedString )
42
+ public void IterateLines ( Action < string > action , params string [ ] thatContain )
45
43
{
46
- using var file = File . OpenRead ( logFile . FullFilename ) ;
47
- using var streamReader = new StreamReader ( file ) ;
48
- var lines = new List < string > ( ) ;
49
-
50
- var line = streamReader . ReadLine ( ) ;
51
- while ( line != null )
44
+ IterateLines ( line =>
52
45
{
53
- if ( line . Contains ( expectedString ) )
46
+ if ( thatContain . All ( line . Contains ) )
54
47
{
55
- lines . Add ( line ) ;
48
+ action ( line ) ;
56
49
}
57
- line = streamReader . ReadLine ( ) ;
58
- }
50
+ } ) ;
51
+ }
59
52
60
- return lines . ToArray ( ) ; ;
53
+ public string [ ] GetLinesContaining ( string expectedString )
54
+ {
55
+ return FindLinesThatContain ( [ expectedString ] ) ;
61
56
}
62
57
63
58
public string [ ] FindLinesThatContain ( params string [ ] tags )
64
59
{
65
60
var result = new List < string > ( ) ;
66
- using var file = File . OpenRead ( logFile . FullFilename ) ;
67
- using var streamReader = new StreamReader ( file ) ;
68
-
69
- var line = streamReader . ReadLine ( ) ;
70
- while ( line != null )
71
- {
72
- if ( tags . All ( line . Contains ) )
73
- {
74
- result . Add ( line ) ;
75
- }
76
-
77
- line = streamReader . ReadLine ( ) ;
78
- }
79
-
61
+ IterateLines ( result . Add , tags ) ;
80
62
return result . ToArray ( ) ;
81
63
}
82
64
0 commit comments