@@ -102,7 +102,7 @@ public static partial class ConditionFactory
102
102
/// <summary>
103
103
/// Enumeration of the supported ways an ARN comparison can be evaluated.
104
104
/// </summary>
105
- public enum ArnComparisonType
105
+ public enum ArnComparisonType
106
106
{
107
107
/// <summary>Exact matching</summary>
108
108
ArnEquals ,
@@ -177,7 +177,7 @@ public enum NumericComparisonType
177
177
/// <summary>
178
178
/// Enumeration of the supported ways a string comparison can be evaluated.
179
179
/// </summary>
180
- public enum StringComparisonType
180
+ public enum StringComparisonType
181
181
{
182
182
/// <summary>
183
183
/// Case-sensitive exact string matching
@@ -220,9 +220,9 @@ public enum StringComparisonType
220
220
/// <param name="type">The type of comparison to perform.</param>
221
221
/// <param name="value">The second ARN to compare against. When using ArnLike or ArnNotLike this may contain the
222
222
/// multi-character wildcard (*) or the single-character wildcard</param>
223
- public static Condition NewCondition ( ArnComparisonType type , string key , string value )
223
+ public static Condition NewCondition ( ArnComparisonType type , string key , string value )
224
224
{
225
- return new Condition ( type . ToString ( ) , key , value ) ;
225
+ return new Condition ( ToString ( type ) , key , value ) ;
226
226
}
227
227
228
228
/// <summary>
@@ -234,7 +234,7 @@ public static Condition NewCondition(ArnComparisonType type, string key, string
234
234
/// <param name="value">The boolean to compare against.</param>
235
235
public static Condition NewCondition ( string key , bool value )
236
236
{
237
- return new Condition ( "Bool" , key , value . ToString ( ) . ToLowerInvariant ( ) ) ;
237
+ return new Condition ( "Bool" , key , value ? "true" : "false" ) ;
238
238
}
239
239
240
240
/// <summary>
@@ -251,7 +251,7 @@ public static Condition NewCondition(string key, bool value)
251
251
[ Obsolete ( "Invoking this method results in non-UTC DateTimes not being marshalled correctly. Use NewConditionUtc instead." , false ) ]
252
252
public static Condition NewCondition ( DateComparisonType type , DateTime date )
253
253
{
254
- return new Condition ( type . ToString ( ) , CURRENT_TIME_CONDITION_KEY , date . ToString ( AWSSDKUtils . ISO8601DateFormat , CultureInfo . InvariantCulture ) ) ;
254
+ return new Condition ( ToString ( type ) , CURRENT_TIME_CONDITION_KEY , date . ToString ( AWSSDKUtils . ISO8601DateFormat , CultureInfo . InvariantCulture ) ) ;
255
255
}
256
256
257
257
/// <summary>
@@ -265,7 +265,7 @@ public static Condition NewCondition(DateComparisonType type, DateTime date)
265
265
/// <param name="date">The date to compare against.</param>
266
266
public static Condition NewConditionUtc ( DateComparisonType type , DateTime date )
267
267
{
268
- return new Condition ( type . ToString ( ) , CURRENT_TIME_CONDITION_KEY , date . ToUniversalTime ( ) . ToString ( AWSSDKUtils . ISO8601DateFormat , CultureInfo . InvariantCulture ) ) ;
268
+ return new Condition ( ToString ( type ) , CURRENT_TIME_CONDITION_KEY , date . ToUniversalTime ( ) . ToString ( AWSSDKUtils . ISO8601DateFormat , CultureInfo . InvariantCulture ) ) ;
269
269
}
270
270
271
271
/// <summary>
@@ -298,7 +298,7 @@ public static Condition NewIpAddressCondition(string ipAddressRange)
298
298
/// <param name="ipAddressRange">The CIDR IP range involved in the policy condition.</param>
299
299
public static Condition NewCondition ( IpAddressComparisonType type , string ipAddressRange )
300
300
{
301
- return new Condition ( type . ToString ( ) , SOURCE_IP_CONDITION_KEY , ipAddressRange ) ;
301
+ return new Condition ( ToString ( type ) , SOURCE_IP_CONDITION_KEY , ipAddressRange ) ;
302
302
}
303
303
304
304
/// <summary>
@@ -310,7 +310,7 @@ public static Condition NewCondition(IpAddressComparisonType type, string ipAddr
310
310
/// <param name="value">The second number to compare against.</param>
311
311
public static Condition NewCondition ( NumericComparisonType type , string key , string value )
312
312
{
313
- return new Condition ( type . ToString ( ) , key , value ) ;
313
+ return new Condition ( ToString ( type ) , key , value ) ;
314
314
}
315
315
316
316
/// <summary>
@@ -329,7 +329,7 @@ public static Condition NewCondition(NumericComparisonType type, string key, str
329
329
/// </param>
330
330
public static Condition NewCondition ( StringComparisonType type , string key , string value )
331
331
{
332
- return new Condition ( type . ToString ( ) , key , value ) ;
332
+ return new Condition ( ToString ( type ) , key , value ) ;
333
333
}
334
334
335
335
/// <summary>
@@ -376,5 +376,98 @@ public static Condition NewSecureTransportCondition()
376
376
{
377
377
return NewCondition ( SECURE_TRANSPORT_CONDITION_KEY , true ) ;
378
378
}
379
+
380
+ private static string ToString ( ArnComparisonType type )
381
+ {
382
+ switch ( type )
383
+ {
384
+ case ArnComparisonType . ArnEquals :
385
+ return nameof ( ArnComparisonType . ArnEquals ) ;
386
+ case ArnComparisonType . ArnLike :
387
+ return nameof ( ArnComparisonType . ArnLike ) ;
388
+ case ArnComparisonType . ArnNotEquals :
389
+ return nameof ( ArnComparisonType . ArnNotEquals ) ;
390
+ case ArnComparisonType . ArnNotLike :
391
+ return nameof ( ArnComparisonType . ArnNotLike ) ;
392
+ default :
393
+ return type . ToString ( ) ;
394
+ }
395
+ }
396
+
397
+ private static string ToString ( DateComparisonType type )
398
+ {
399
+ switch ( type )
400
+ {
401
+ case DateComparisonType . DateEquals :
402
+ return nameof ( DateComparisonType . DateEquals ) ;
403
+ case DateComparisonType . DateGreaterThan :
404
+ return nameof ( DateComparisonType . DateGreaterThan ) ;
405
+ case DateComparisonType . DateGreaterThanEquals :
406
+ return nameof ( DateComparisonType . DateGreaterThanEquals ) ;
407
+ case DateComparisonType . DateLessThan :
408
+ return nameof ( DateComparisonType . DateLessThan ) ;
409
+ case DateComparisonType . DateLessThanEquals :
410
+ return nameof ( DateComparisonType . DateLessThanEquals ) ;
411
+ case DateComparisonType . DateNotEquals :
412
+ return nameof ( DateComparisonType . DateNotEquals ) ;
413
+ default :
414
+ return type . ToString ( ) ;
415
+ }
416
+ }
417
+
418
+ private static string ToString ( IpAddressComparisonType type )
419
+ {
420
+ switch ( type )
421
+ {
422
+ case IpAddressComparisonType . IpAddress :
423
+ return nameof ( IpAddressComparisonType . IpAddress ) ;
424
+ case IpAddressComparisonType . NotIpAddress :
425
+ return nameof ( IpAddressComparisonType . NotIpAddress ) ;
426
+ default :
427
+ return type . ToString ( ) ;
428
+ }
429
+ }
430
+
431
+ private static string ToString ( NumericComparisonType type )
432
+ {
433
+ switch ( type )
434
+ {
435
+ case NumericComparisonType . NumericEquals :
436
+ return nameof ( NumericComparisonType . NumericEquals ) ;
437
+ case NumericComparisonType . NumericGreaterThan :
438
+ return nameof ( NumericComparisonType . NumericGreaterThan ) ;
439
+ case NumericComparisonType . NumericGreaterThanEquals :
440
+ return nameof ( NumericComparisonType . NumericGreaterThanEquals ) ;
441
+ case NumericComparisonType . NumericLessThan :
442
+ return nameof ( NumericComparisonType . NumericLessThan ) ;
443
+ case NumericComparisonType . NumericLessThanEquals :
444
+ return nameof ( NumericComparisonType . NumericLessThanEquals ) ;
445
+ case NumericComparisonType . NumericNotEquals :
446
+ return nameof ( NumericComparisonType . NumericNotEquals ) ;
447
+ default :
448
+ return type . ToString ( ) ;
449
+ }
450
+ }
451
+
452
+ private static string ToString ( StringComparisonType type )
453
+ {
454
+ switch ( type )
455
+ {
456
+ case StringComparisonType . StringEquals :
457
+ return nameof ( StringComparisonType . StringEquals ) ;
458
+ case StringComparisonType . StringEqualsIgnoreCase :
459
+ return nameof ( StringComparisonType . StringEqualsIgnoreCase ) ;
460
+ case StringComparisonType . StringLike :
461
+ return nameof ( StringComparisonType . StringLike ) ;
462
+ case StringComparisonType . StringNotEquals :
463
+ return nameof ( StringComparisonType . StringNotEquals ) ;
464
+ case StringComparisonType . StringNotEqualsIgnoreCase :
465
+ return nameof ( StringComparisonType . StringNotEqualsIgnoreCase ) ;
466
+ case StringComparisonType . StringNotLike :
467
+ return nameof ( StringComparisonType . StringNotLike ) ;
468
+ default :
469
+ return type . ToString ( ) ;
470
+ }
471
+ }
379
472
}
380
473
}
0 commit comments