1- using System ;
2- using System . Collections . Generic ;
1+ using System . Collections . Generic ;
32using System . Linq ;
4- using System . Text ;
53using System . Text . RegularExpressions ;
6- using System . Threading . Tasks ;
74using ThermoFisher . CommonCore . Data . Business ;
85
96namespace ThermoRawFileParser . Writer
@@ -16,7 +13,7 @@ public class ScanTrailer
1613
1714 public string [ ] Values { get => data . Values . ToArray ( ) ; }
1815
19- private Dictionary < string , string > data ;
16+ private readonly Dictionary < string , string > data ;
2017
2118 public ScanTrailer ( LogEntry trailerData )
2219 {
@@ -28,6 +25,11 @@ public ScanTrailer(LogEntry trailerData)
2825 }
2926 }
3027
28+ /// <summary>
29+ /// Try returning selected trailer element as boolean value,
30+ /// if the element does not exist or cannot be converted to boolean return null
31+ /// </summary>
32+ /// <param name="key">name of the element</param>
3133 public bool ? AsBool ( string key )
3234 {
3335 if ( data . ContainsKey ( key ) )
@@ -48,6 +50,11 @@ public ScanTrailer(LogEntry trailerData)
4850 return null ;
4951 }
5052
53+ /// <summary>
54+ /// Try returning selected trailer element as double value,
55+ /// if the element does not exist or cannot be converted to double return null
56+ /// </summary>
57+ /// <param name="key">name of the element</param>
5158 public double ? AsDouble ( string key )
5259 {
5360 if ( data . ContainsKey ( key ) )
@@ -57,6 +64,11 @@ public ScanTrailer(LogEntry trailerData)
5764 return null ;
5865 }
5966
67+ /// <summary>
68+ /// Try returning selected trailer element as integer value,
69+ /// if the element does not exist or cannot be converted to integer return null
70+ /// </summary>
71+ /// <param name="key">name of the element</param>
6072 public int ? AsInt ( string key )
6173 {
6274 if ( data . ContainsKey ( key ) )
@@ -66,6 +78,11 @@ public ScanTrailer(LogEntry trailerData)
6678 return null ;
6779 }
6880
81+ /// <summary>
82+ /// Try returning selected trailer element as strictly positive (non zero) integer value,
83+ /// if the element does not exist or cannot be converted to strictly positive integer return null
84+ /// </summary>
85+ /// <param name="key">name of the element</param>
6986 public int ? AsPositiveInt ( string key )
7087 {
7188 int ? value = AsInt ( key ) ;
@@ -75,11 +92,21 @@ public ScanTrailer(LogEntry trailerData)
7592
7693 }
7794
95+ /// <summary>
96+ /// Try returning selected trailer element as string,
97+ /// alias to `Get`
98+ /// </summary>
99+ /// <param name="key">name of the element</param>
78100 public string AsString ( string key )
79101 {
80102 return Get ( key ) ;
81103 }
82104
105+ /// <summary>
106+ /// Try getting selected trailer element by name,
107+ /// if the element does not exist return null
108+ /// </summary>
109+ /// <param name="key">name of the element</param>
83110 public string Get ( string key )
84111 {
85112 if ( data . ContainsKey ( key ) )
@@ -89,16 +116,28 @@ public string Get(string key)
89116 return null ;
90117 }
91118
119+ /// <summary>
120+ /// Check if selected trailer element exists
121+ /// </summary>
122+ /// <param name="key">name of the element</param>
92123 public bool Has ( string key )
93124 {
94125 return data . ContainsKey ( key ) ;
95126 }
96127
128+ /// <summary>
129+ /// Return iterator over trailer element names matching regex
130+ /// </summary>
131+ /// <param name="regex">compiled regex object</param>
97132 public IEnumerable < string > MatchKeys ( Regex regex )
98133 {
99134 return data . Keys . Where ( k => regex . IsMatch ( k ) ) ;
100135 }
101136
137+ /// <summary>
138+ /// Return iterator over trailer element values which names are matching regex
139+ /// </summary>
140+ /// <param name="regex">compiled regex object</param>
102141 public IEnumerable < string > MatchValues ( Regex regex )
103142 {
104143 return data . Where ( item => regex . IsMatch ( item . Key ) ) . Select ( item => item . Value ) ;
0 commit comments