@@ -8,7 +8,7 @@ namespace ZippyNeuron.Metarwiz.Parser;
88
99internal sealed class MetarParser : IMetarParser
1010{
11- private readonly List < MetarParserItem > _items = new ( ) ;
11+ private readonly List < MetarParserItem > _items = [ ] ;
1212 private readonly MetarInfo _metarInfo ;
1313
1414 internal MetarParser ( string metar , string tag = null )
@@ -20,11 +20,10 @@ internal MetarParser(string metar, string tag = null)
2020
2121 public MetarInfo Info => _metarInfo ;
2222
23- public IEnumerable < IMetarItem > Items => _items
23+ public IEnumerable < IMetarItem > Items => [ .. _items
2424 . OrderBy ( i => i . Index )
2525 . Select ( ( value ) => value . Item )
26- . Cast < IMetarItem > ( )
27- . ToList ( ) ;
26+ . Cast < IMetarItem > ( ) ] ;
2827
2928 public void Parse ( )
3029 {
@@ -41,9 +40,7 @@ private void ParseTypes(string metar, IEnumerable<Type> types)
4140
4241 foreach ( var type in types )
4342 {
44- var pattern = GetMatchPattern ( type ) ;
45-
46- var matchCollection = Regex . Matches ( metarCopy , pattern , RegexOptions . None ) ;
43+ var matchCollection = GetRegex ( type ) . Matches ( metarCopy ) ;
4744
4845 if ( matchCollection . Count <= 0 ) continue ;
4946
@@ -69,9 +66,6 @@ private void ParseTypes(string metar, IEnumerable<Type> types)
6966 }
7067 }
7168
72- private string GetMatchPattern ( Type type )
73- {
74- return type . GetProperty ( "Pattern" , BindingFlags . Static | BindingFlags . NonPublic )
75- ? . GetValue ( null , null ) as string ;
76- }
77- }
69+ private static Regex GetRegex ( Type type ) =>
70+ ( Regex ) type . GetMethod ( "Pattern" , BindingFlags . Static | BindingFlags . NonPublic ) ? . Invoke ( null , null ) ;
71+ }
0 commit comments