Skip to content

Commit d380e90

Browse files
committed
made all the Dictionary<string,string> case insensitive.
1 parent a69e839 commit d380e90

7 files changed

Lines changed: 18 additions & 25 deletions

File tree

Synapse.Common/CmdLine/HttpApiCliBase.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ protected virtual List<object> GetMethodParameters(string[] args, int cmdlineSta
6161
for( int i = parmsStartIndex; i < parms.Length; i++ )
6262
{
6363
ParameterInfo parm = parms[i];
64-
if( options.Keys.Contains( parm.Name.ToLower() ) )
65-
parameters.Add( ParseInput( options[parm.Name.ToLower()], parm.ParameterType ) );
64+
if( options.Keys.Contains( parm.Name ) ) //.ToLower()
65+
parameters.Add( ParseInput( options[parm.Name], parm.ParameterType ) ); //.ToLower()
6666
else
6767
parameters.Add( null );
6868
}
@@ -73,7 +73,7 @@ protected virtual List<object> GetMethodParameters(string[] args, int cmdlineSta
7373

7474
protected virtual Dictionary<string, string> ParseCmdLine(string[] args, int startIndex, ref bool error, bool suppressErrorMessages = false)
7575
{
76-
Dictionary<string, string> options = new Dictionary<string, string>();
76+
Dictionary<string, string> options = new Dictionary<string, string>( StringComparer.OrdinalIgnoreCase );
7777

7878
if( args.Length < (startIndex + 1) )
7979
{
@@ -90,7 +90,7 @@ protected virtual Dictionary<string, string> ParseCmdLine(string[] args, int sta
9090

9191
// If match not found, command line args are improperly formed.
9292
if( match.Success )
93-
options[match.Groups["argname"].Value.ToLower()] = match.Groups["argvalue"].Value; //.ToLower();
93+
options[match.Groups["argname"].Value] = match.Groups["argvalue"].Value; //.ToLower();.ToLower()
9494
else if( !suppressErrorMessages )
9595
WriteHelpAndExit( "The command line arguments are not valid or are improperly formed. Use 'argname:argvalue' for extended arguments." );
9696
}
@@ -231,7 +231,7 @@ public class CmdLineUtilities
231231
{
232232
public static Dictionary<string, string> ParseCmdLine(string[] args, int startIndex, ref bool error, ref string message, Action<string> onErrorMethod, bool suppressErrorMessages = false)
233233
{
234-
Dictionary<string, string> options = new Dictionary<string, string>();
234+
Dictionary<string, string> options = new Dictionary<string, string>( StringComparer.OrdinalIgnoreCase );
235235

236236
if( args.Length < (startIndex + 1) )
237237
{
@@ -250,7 +250,7 @@ public static Dictionary<string, string> ParseCmdLine(string[] args, int startIn
250250
// If match not found, command line args are improperly formed.
251251
if( match.Success )
252252
{
253-
options[match.Groups["argname"].Value.ToLower()] = match.Groups["argvalue"].Value.ToLower();
253+
options[match.Groups["argname"].Value] = match.Groups["argvalue"].Value; //.ToLower();.ToLower()
254254
}
255255
else
256256
{

Synapse.Common/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@
3838
// by using the '*' as shown below:
3939
// [assembly: AssemblyVersion("1.0.*")]
4040
[assembly: AssemblyVersion( "0.1.0.0" )]
41-
[assembly: AssemblyFileVersion( "0.1.17143.0" )]
41+
[assembly: AssemblyFileVersion( "0.1.17144.0" )]

Synapse.Common/Utilities/Utilities.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static string ToQueryString(this IDictionary<string, string> dynamicData,
3939
public static Dictionary<string, string> ParseQueryString(this Uri uri)
4040
{
4141
NameValueCollection nvc = HttpUtility.ParseQueryString( uri.Query );
42-
Dictionary<string, string> d = new Dictionary<string, string>( nvc.Count );
42+
Dictionary<string, string> d = new Dictionary<string, string>( nvc.Count, StringComparer.OrdinalIgnoreCase );
4343
foreach( string key in nvc.AllKeys )
4444
d[key] = nvc[key];
4545
return d;

Synapse.Core/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@
3737
// by using the '*' as shown below:
3838
// [assembly: AssemblyVersion("1.0.*")]
3939
[assembly: AssemblyVersion( "0.1.0.0" )]
40-
[assembly: AssemblyFileVersion( "0.1.17143.0" )]
40+
[assembly: AssemblyFileVersion( "0.1.17144.0" )]

Synapse.Core/Runtime/ParameterInfoRuntime.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public partial class ParameterInfo : IParameterInfo
1616

1717
public object Resolve(out List<object> forEachParms, Dictionary<string, string> dynamicData = null)
1818
{
19-
_dynamicData = dynamicData ?? new Dictionary<string, string>();
19+
_dynamicData = dynamicData ?? new Dictionary<string, string>( StringComparer.OrdinalIgnoreCase );
2020
forEachParms = new List<object>();
2121

2222
object parms = null;

Synapse.cli/Program.cs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,9 @@ public Arguments(string[] args)
330330

331331
if( IsParsed )
332332
{
333-
Dictionary<string, string> origcase = new Dictionary<string, string>();
334-
Args = ParseCmdLine( args, ref origcase );
333+
Args = ParseCmdLine( args );
335334

335+
#region known parms
336336
#region Plan
337337
if( Args.Keys.Contains( __plan ) )
338338
{
@@ -498,12 +498,7 @@ public Arguments(string[] args)
498498
Verbose = false;
499499
}
500500
#endregion
501-
502-
//this returns a colleection with original casing from the cmdline parms
503-
Dictionary<string, string> newArgs = new Dictionary<string, string>();
504-
foreach( string key in Args.Keys )
505-
newArgs.Add( origcase[key], Args[key] );
506-
Args = newArgs;
501+
#endregion
507502
}
508503

509504
IsParsed &= string.IsNullOrWhiteSpace( Message );
@@ -530,10 +525,10 @@ public Arguments(string[] args)
530525
public bool IsSample { get { return !string.IsNullOrWhiteSpace( Sample ); } }
531526
public bool Verbose { get; internal set; }
532527

533-
Dictionary<string, string> ParseCmdLine(string[] args, ref Dictionary<string, string> origcase)
528+
Dictionary<string, string> ParseCmdLine(string[] args)
534529
{
535530
IsParsed = true;
536-
Dictionary<string, string> options = new Dictionary<string, string>();
531+
Dictionary<string, string> options = new Dictionary<string, string>( StringComparer.OrdinalIgnoreCase );
537532

538533
string pattern = "(?<argname>.*?):(?<argvalue>.*)";
539534
//string pattern = @"(?<argname>/\w+):(?<argvalue>.*)";
@@ -544,10 +539,8 @@ Dictionary<string, string> ParseCmdLine(string[] args, ref Dictionary<string, st
544539
// If match not found, command line args are improperly formed.
545540
if( match.Success )
546541
{
547-
string orig = match.Groups["argname"].Value.TrimStart( '/' );
548-
string lcase = orig.ToLower();
549-
options[lcase] = match.Groups["argvalue"].Value;
550-
origcase[lcase] = orig;
542+
options[match.Groups["argname"].Value.TrimStart( '/' )] = //.ToLower()
543+
match.Groups["argvalue"].Value;
551544
}
552545
else
553546
{

Synapse.cli/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
3535
[assembly: AssemblyVersion( "0.1.0.0" )]
36-
[assembly: AssemblyFileVersion( "0.1.17143.0" )]
36+
[assembly: AssemblyFileVersion( "0.1.17144.0" )]

0 commit comments

Comments
 (0)