@@ -109,25 +109,24 @@ private static void Main()
109
109
110
110
var fileConfig = config . GetSection ( "Files" ) ;
111
111
112
- Global . Bidirectional = fileConfig [ "Bidirectional" ] ? . ToUpperInvariant ( ) != "FALSE" ; //default is true
112
+ Global . Bidirectional = fileConfig . GetTextUpper ( "Bidirectional" ) != "FALSE" ; //default is true
113
113
114
- Global . AsyncPath = fileConfig [ "AsyncPath" ] ;
115
- Global . SyncPath = fileConfig [ "SyncPath" ] ;
114
+ Global . AsyncPath = fileConfig . GetTextUpperOnWindows ( "AsyncPath" ) ;
115
+ Global . SyncPath = fileConfig . GetTextUpperOnWindows ( "SyncPath" ) ;
116
116
117
- Global . WatchedCodeExtension = fileConfig . GetSection ( "WatchedCodeExtension" ) . GetChildren ( ) . Select ( c => c . Value . ToUpperInvariant ( ) ) . ToList ( ) ;
118
- Global . WatchedResXExtension = fileConfig . GetSection ( "WatchedResXExtension" ) . GetChildren ( ) . Select ( c => c . Value . ToUpperInvariant ( ) ) . ToList ( ) ;
117
+ Global . WatchedCodeExtension = fileConfig . GetListUpperOnWindows ( "WatchedCodeExtensions" , "WatchedCodeExtension" ) ;
118
+ Global . WatchedResXExtension = fileConfig . GetListUpperOnWindows ( "WatchedResXExtensions" , "WatchedResXExtension" ) ;
119
119
120
120
//this would need Microsoft.Extensions.Configuration and Microsoft.Extensions.Configuration.Binder packages
121
- //Global.ExcludedExtensions = fileConfig.GetSection("ExcludedExtensions").Get<string[]>();
122
- Global . ExcludedExtensions = fileConfig . GetSection ( "ExcludedExtensions" ) . GetChildren ( ) . Select ( c => c . Value . ToUpperInvariant ( ) ) . ToList ( ) ; //NB! .ToUpperInvariant()
121
+ Global . ExcludedExtensions = fileConfig . GetListUpperOnWindows ( "ExcludedExtensions" , "ExcludedExtension" ) ; //NB! UpperOnWindows
123
122
124
- Global . IgnorePathsStartingWith = fileConfig . GetSection ( "IgnorePathsStartingWith" ) . GetChildren ( ) . Select ( c => c . Value . ToUpperInvariant ( ) ) . ToList ( ) ; //NB! .ToUpperInvariant()
125
- Global . IgnorePathsContaining = fileConfig . GetSection ( "IgnorePathsContaining" ) . GetChildren ( ) . Select ( c => c . Value . ToUpperInvariant ( ) ) . ToList ( ) ; //NB! .ToUpperInvariant()
123
+ Global . IgnorePathsStartingWith = fileConfig . GetListUpperOnWindows ( "IgnorePathsStartingWith" , "IgnorePathStartingWith" ) ; //NB! UpperOnWindows
124
+ Global . IgnorePathsContaining = fileConfig . GetListUpperOnWindows ( "IgnorePathsContaining" , "IgnorePathContaining" ) ; //NB! UpperOnWindows
126
125
127
126
128
127
var pathHashes = "" ;
129
- pathHashes += "_" + GetHashString ( Global . AsyncPath . ToUpperInvariant ( ) ) ;
130
- pathHashes += "_" + GetHashString ( Global . SyncPath . ToUpperInvariant ( ) ) ;
128
+ pathHashes += "_" + GetHashString ( Global . AsyncPath ) ;
129
+ pathHashes += "_" + GetHashString ( Global . SyncPath ) ;
131
130
132
131
//NB! prevent multiple instances from starting on same directories
133
132
using ( Mutex mutex = new Mutex ( false , "Global\\ AsyncToSyncCodeRoundtripSynchroniserMonitor_" + pathHashes ) )
@@ -414,11 +413,13 @@ public static async Task WriteException(Exception ex, Context context)
414
413
415
414
public static string GetNonFullName ( string fullName )
416
415
{
417
- if ( fullName . ToUpperInvariant ( ) . StartsWith ( Global . AsyncPath . ToUpperInvariant ( ) ) )
416
+ var fullNameInvariant = fullName . ToUpperInvariantOnWindows ( ) ;
417
+
418
+ if ( fullNameInvariant . StartsWith ( Global . AsyncPath ) )
418
419
{
419
420
return fullName . Substring ( Global . AsyncPath . Length ) ;
420
421
}
421
- else if ( fullName . ToUpperInvariant ( ) . StartsWith ( Global . SyncPath . ToUpperInvariant ( ) ) )
422
+ else if ( fullNameInvariant . StartsWith ( Global . SyncPath ) )
422
423
{
423
424
return fullName . Substring ( Global . SyncPath . Length ) ;
424
425
}
@@ -430,13 +431,14 @@ public static string GetNonFullName(string fullName)
430
431
431
432
public static string GetOtherFullName ( string fullName )
432
433
{
434
+ var fullNameInvariant = fullName . ToUpperInvariantOnWindows ( ) ;
433
435
var nonFullName = GetNonFullName ( fullName ) ;
434
436
435
- if ( fullName . ToUpperInvariant ( ) . StartsWith ( Global . AsyncPath . ToUpperInvariant ( ) ) )
437
+ if ( fullNameInvariant . StartsWith ( Global . AsyncPath ) )
436
438
{
437
439
return Path . Combine ( Global . SyncPath , nonFullName ) ;
438
440
}
439
- else if ( fullName . ToUpperInvariant ( ) . StartsWith ( Global . SyncPath . ToUpperInvariant ( ) ) )
441
+ else if ( fullNameInvariant . StartsWith ( Global . SyncPath ) )
440
442
{
441
443
return Path . Combine ( Global . AsyncPath , nonFullName ) ;
442
444
}
@@ -533,18 +535,18 @@ public static async Task FileUpdated(string fullName, Context context)
533
535
var otherFullName = GetOtherFullName ( fullName ) ;
534
536
using ( await Global . FileOperationLocks . LockAsync ( fullName , otherFullName , context . Token ) )
535
537
{
536
- var fullNameInvariant = fullName . ToUpperInvariant ( ) ;
538
+ var fullNameInvariant = fullName . ToUpperInvariantOnWindows ( ) ;
537
539
538
540
if (
539
- Global . WatchedCodeExtension . Any ( x => fullNameInvariant . EndsWith ( "." + x . ToUpperInvariant ( ) ) )
541
+ Global . WatchedCodeExtension . Any ( x => fullNameInvariant . EndsWith ( "." + x ) )
540
542
|| Global . WatchedCodeExtension . Contains ( "*" )
541
543
)
542
544
{
543
- if ( fullName . ToUpperInvariant ( ) . StartsWith ( Global . AsyncPath . ToUpperInvariant ( ) ) )
545
+ if ( fullNameInvariant . StartsWith ( Global . AsyncPath ) )
544
546
{
545
547
await AsyncToSyncConverter . AsyncFileUpdated ( fullName , context ) ;
546
548
}
547
- else if ( fullName . ToUpperInvariant ( ) . StartsWith ( Global . SyncPath . ToUpperInvariant ( ) ) ) //NB!
549
+ else if ( fullNameInvariant . StartsWith ( Global . SyncPath ) ) //NB!
548
550
{
549
551
await SyncToAsyncConverter . SyncFileUpdated ( fullName , context ) ;
550
552
}
@@ -600,12 +602,12 @@ private static DateTime GetFileTime(string fullName)
600
602
601
603
private static bool IsWatchedFile ( string fullName )
602
604
{
603
- var fullNameInvariant = fullName . ToUpperInvariant ( ) ;
605
+ var fullNameInvariant = fullName . ToUpperInvariantOnWindows ( ) ;
604
606
605
607
if (
606
608
(
607
- Global . WatchedCodeExtension . Any ( x => fullNameInvariant . EndsWith ( "." + x . ToUpperInvariant ( ) ) )
608
- || Global . WatchedResXExtension . Any ( x => fullNameInvariant . EndsWith ( "." + x . ToUpperInvariant ( ) ) )
609
+ Global . WatchedCodeExtension . Any ( x => fullNameInvariant . EndsWith ( "." + x ) )
610
+ || Global . WatchedResXExtension . Any ( x => fullNameInvariant . EndsWith ( "." + x ) )
609
611
|| Global . WatchedCodeExtension . Contains ( "*" )
610
612
|| Global . WatchedResXExtension . Contains ( "*" )
611
613
)
0 commit comments