1- namespace tomenglertde . ResXManager . Model
2- {
3- using System ;
4- using System . Diagnostics ;
5- using System . Diagnostics . CodeAnalysis ;
6- using System . Diagnostics . Contracts ;
7- using System . IO ;
8- using System . Linq ;
9- using System . Text . RegularExpressions ;
10-
11- using JetBrains . Annotations ;
12-
13- using tomenglertde . ResXManager . Infrastructure ;
14-
15- public class FileFilter : IFileFilter
16- {
1+ namespace tomenglertde . ResXManager . Model
2+ {
3+ using System ;
4+ using System . Diagnostics ;
5+ using System . Diagnostics . CodeAnalysis ;
6+ using System . Diagnostics . Contracts ;
7+ using System . IO ;
8+ using System . Linq ;
9+ using System . Text . RegularExpressions ;
10+
11+ using JetBrains . Annotations ;
12+
13+ using tomenglertde . ResXManager . Infrastructure ;
14+
15+ public class FileFilter : IFileFilter
16+ {
1717 [ NotNull ]
1818 [ ItemNotNull ]
1919 private readonly string [ ] _extensions ;
2020 [ CanBeNull ]
21- private readonly Regex _fileExclusionFilter ;
22-
23- public FileFilter ( [ NotNull ] Configuration configuration )
24- {
25- Contract . Requires ( configuration != null ) ;
26-
27- _extensions = configuration . CodeReferences
28- . Items . SelectMany ( item => item . ParseExtensions ( ) )
29- . Distinct ( )
30- . ToArray ( ) ;
31-
32- _fileExclusionFilter = configuration . FileExclusionFilter . TryCreateRegex ( ) ;
33- }
34-
35- public bool IsSourceFile ( ProjectFile file )
36- {
37- return _extensions . Contains ( file . Extension , StringComparer . OrdinalIgnoreCase ) ;
38- }
39-
40- public bool IncludeFile ( FileInfo fileInfo )
41- {
42- return _fileExclusionFilter ? . IsMatch ( fileInfo . FullName ) != true ;
43- }
44-
45- [ ContractInvariantMethod ]
46- [ SuppressMessage ( "Microsoft.Performance" , "CA1822:MarkMembersAsStatic" , Justification = "Required for code contracts." ) ]
47- [ Conditional ( "CONTRACTS_FULL" ) ]
48- private void ObjectInvariant ( )
49- {
50- Contract . Invariant ( _extensions != null ) ;
51- }
52- }
21+ private readonly Regex _fileExclusionFilter ;
22+
23+ public FileFilter ( [ NotNull ] Configuration configuration )
24+ {
25+ Contract . Requires ( configuration != null ) ;
26+
27+ _extensions = configuration . CodeReferences
28+ . Items . SelectMany ( item => item . ParseExtensions ( ) )
29+ . Distinct ( )
30+ . ToArray ( ) ;
31+
32+ _fileExclusionFilter = configuration . FileExclusionFilter . TryCreateRegex ( ) ;
33+ }
34+
35+ public bool IsSourceFile ( ProjectFile file )
36+ {
37+ return _extensions . Contains ( file . Extension , StringComparer . OrdinalIgnoreCase ) ;
38+ }
39+
40+ public bool IncludeFile ( ProjectFile file )
41+ {
42+ return _fileExclusionFilter ? . IsMatch ( file . RelativeFilePath ) != true ;
43+ }
44+
45+ [ ContractInvariantMethod ]
46+ [ SuppressMessage ( "Microsoft.Performance" , "CA1822:MarkMembersAsStatic" , Justification = "Required for code contracts." ) ]
47+ [ Conditional ( "CONTRACTS_FULL" ) ]
48+ private void ObjectInvariant ( )
49+ {
50+ Contract . Invariant ( _extensions != null ) ;
51+ }
52+ }
5353}
0 commit comments