@@ -109,25 +109,24 @@ private static void Main()
109109
110110 var fileConfig = config . GetSection ( "Files" ) ;
111111
112- Global . Bidirectional = fileConfig [ "Bidirectional" ] ? . ToUpperInvariant ( ) != "FALSE" ; //default is true
112+ Global . Bidirectional = fileConfig . GetTextUpper ( "Bidirectional" ) != "FALSE" ; //default is true
113113
114- Global . AsyncPath = fileConfig [ "AsyncPath" ] ;
115- Global . SyncPath = fileConfig [ "SyncPath" ] ;
114+ Global . AsyncPath = fileConfig . GetTextUpperOnWindows ( "AsyncPath" ) ;
115+ Global . SyncPath = fileConfig . GetTextUpperOnWindows ( "SyncPath" ) ;
116116
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" ) ;
119119
120120 //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
123122
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
126125
127126
128127 var pathHashes = "" ;
129- pathHashes += "_" + GetHashString ( Global . AsyncPath . ToUpperInvariant ( ) ) ;
130- pathHashes += "_" + GetHashString ( Global . SyncPath . ToUpperInvariant ( ) ) ;
128+ pathHashes += "_" + GetHashString ( Global . AsyncPath ) ;
129+ pathHashes += "_" + GetHashString ( Global . SyncPath ) ;
131130
132131 //NB! prevent multiple instances from starting on same directories
133132 using ( Mutex mutex = new Mutex ( false , "Global\\ AsyncToSyncCodeRoundtripSynchroniserMonitor_" + pathHashes ) )
@@ -414,11 +413,13 @@ public static async Task WriteException(Exception ex, Context context)
414413
415414 public static string GetNonFullName ( string fullName )
416415 {
417- if ( fullName . ToUpperInvariant ( ) . StartsWith ( Global . AsyncPath . ToUpperInvariant ( ) ) )
416+ var fullNameInvariant = fullName . ToUpperInvariantOnWindows ( ) ;
417+
418+ if ( fullNameInvariant . StartsWith ( Global . AsyncPath ) )
418419 {
419420 return fullName . Substring ( Global . AsyncPath . Length ) ;
420421 }
421- else if ( fullName . ToUpperInvariant ( ) . StartsWith ( Global . SyncPath . ToUpperInvariant ( ) ) )
422+ else if ( fullNameInvariant . StartsWith ( Global . SyncPath ) )
422423 {
423424 return fullName . Substring ( Global . SyncPath . Length ) ;
424425 }
@@ -430,13 +431,14 @@ public static string GetNonFullName(string fullName)
430431
431432 public static string GetOtherFullName ( string fullName )
432433 {
434+ var fullNameInvariant = fullName . ToUpperInvariantOnWindows ( ) ;
433435 var nonFullName = GetNonFullName ( fullName ) ;
434436
435- if ( fullName . ToUpperInvariant ( ) . StartsWith ( Global . AsyncPath . ToUpperInvariant ( ) ) )
437+ if ( fullNameInvariant . StartsWith ( Global . AsyncPath ) )
436438 {
437439 return Path . Combine ( Global . SyncPath , nonFullName ) ;
438440 }
439- else if ( fullName . ToUpperInvariant ( ) . StartsWith ( Global . SyncPath . ToUpperInvariant ( ) ) )
441+ else if ( fullNameInvariant . StartsWith ( Global . SyncPath ) )
440442 {
441443 return Path . Combine ( Global . AsyncPath , nonFullName ) ;
442444 }
@@ -533,18 +535,18 @@ public static async Task FileUpdated(string fullName, Context context)
533535 var otherFullName = GetOtherFullName ( fullName ) ;
534536 using ( await Global . FileOperationLocks . LockAsync ( fullName , otherFullName , context . Token ) )
535537 {
536- var fullNameInvariant = fullName . ToUpperInvariant ( ) ;
538+ var fullNameInvariant = fullName . ToUpperInvariantOnWindows ( ) ;
537539
538540 if (
539- Global . WatchedCodeExtension . Any ( x => fullNameInvariant . EndsWith ( "." + x . ToUpperInvariant ( ) ) )
541+ Global . WatchedCodeExtension . Any ( x => fullNameInvariant . EndsWith ( "." + x ) )
540542 || Global . WatchedCodeExtension . Contains ( "*" )
541543 )
542544 {
543- if ( fullName . ToUpperInvariant ( ) . StartsWith ( Global . AsyncPath . ToUpperInvariant ( ) ) )
545+ if ( fullNameInvariant . StartsWith ( Global . AsyncPath ) )
544546 {
545547 await AsyncToSyncConverter . AsyncFileUpdated ( fullName , context ) ;
546548 }
547- else if ( fullName . ToUpperInvariant ( ) . StartsWith ( Global . SyncPath . ToUpperInvariant ( ) ) ) //NB!
549+ else if ( fullNameInvariant . StartsWith ( Global . SyncPath ) ) //NB!
548550 {
549551 await SyncToAsyncConverter . SyncFileUpdated ( fullName , context ) ;
550552 }
@@ -600,12 +602,12 @@ private static DateTime GetFileTime(string fullName)
600602
601603 private static bool IsWatchedFile ( string fullName )
602604 {
603- var fullNameInvariant = fullName . ToUpperInvariant ( ) ;
605+ var fullNameInvariant = fullName . ToUpperInvariantOnWindows ( ) ;
604606
605607 if (
606608 (
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 ) )
609611 || Global . WatchedCodeExtension . Contains ( "*" )
610612 || Global . WatchedResXExtension . Contains ( "*" )
611613 )
0 commit comments