@@ -397,15 +397,15 @@ public List<T> TopLevelWildcardFilter<T>(string resourceGroupName, string name,
397
397
if ( HasProperty < T > ( "ResourceId" ) || HasProperty < T > ( "Id" ) )
398
398
{
399
399
string idProperty = HasProperty < T > ( "ResourceId" ) ? "ResourceId" : "Id" ;
400
- if ( resourceGroupName != null )
400
+ if ( ! string . IsNullOrEmpty ( resourceGroupName ) )
401
401
{
402
402
WildcardPattern pattern = new WildcardPattern ( resourceGroupName , WildcardOptions . IgnoreCase ) ;
403
403
output = output . Select ( t => new { Id = new ResourceIdentifier ( ( string ) GetPropertyValue ( t , idProperty ) ) , Resource = t } )
404
404
. Where ( p => IsMatch ( p . Id , "ResourceGroupName" , pattern ) )
405
405
. Select ( r => r . Resource ) ;
406
406
}
407
407
408
- if ( name != null )
408
+ if ( ! string . IsNullOrEmpty ( name ) )
409
409
{
410
410
WildcardPattern pattern = new WildcardPattern ( name , WildcardOptions . IgnoreCase ) ;
411
411
output = output . Select ( t => new { Id = new ResourceIdentifier ( ( string ) GetPropertyValue ( t , idProperty ) ) , Resource = t } )
@@ -417,14 +417,14 @@ public List<T> TopLevelWildcardFilter<T>(string resourceGroupName, string name,
417
417
else
418
418
{
419
419
// if ResourceGroupName property, filter resource group
420
- if ( HasProperty < T > ( "ResourceGroupName" ) && resourceGroupName != null )
420
+ if ( HasProperty < T > ( "ResourceGroupName" ) && ! string . IsNullOrEmpty ( resourceGroupName ) )
421
421
{
422
422
WildcardPattern pattern = new WildcardPattern ( resourceGroupName , WildcardOptions . IgnoreCase ) ;
423
423
output = output . Where ( t => IsMatch ( t , "ResourceGroupName" , pattern ) ) ;
424
424
}
425
425
426
426
// if Name property, filter name
427
- if ( HasProperty < T > ( "Name" ) && name != null )
427
+ if ( HasProperty < T > ( "Name" ) && ! string . IsNullOrEmpty ( name ) )
428
428
{
429
429
WildcardPattern pattern = new WildcardPattern ( name , WildcardOptions . IgnoreCase ) ;
430
430
output = output . Where ( t => IsMatch ( t , "Name" , pattern ) ) ;
@@ -436,30 +436,7 @@ public List<T> TopLevelWildcardFilter<T>(string resourceGroupName, string name,
436
436
437
437
public List < T > SubResourceWildcardFilter < T > ( string name , IEnumerable < T > resources )
438
438
{
439
- IEnumerable < T > output = resources ;
440
- if ( HasProperty < T > ( "ResourceId" ) || HasProperty < T > ( "Id" ) )
441
- {
442
- string idProperty = HasProperty < T > ( "ResourceId" ) ? "ResourceId" : "Id" ;
443
- if ( name != null )
444
- {
445
- WildcardPattern pattern = new WildcardPattern ( name , WildcardOptions . IgnoreCase ) ;
446
- output = output . Select ( t => new { Id = new ResourceIdentifier ( ( string ) GetPropertyValue ( t , idProperty ) ) , Resource = t } )
447
- . Where ( p => IsMatch ( p . Id , "ResourceName" , pattern ) )
448
- . Select ( r => r . Resource ) ;
449
- }
450
-
451
- }
452
- else
453
- {
454
- // if Name property, filter name
455
- if ( HasProperty < T > ( "Name" ) && name != null )
456
- {
457
- WildcardPattern pattern = new WildcardPattern ( name , WildcardOptions . IgnoreCase ) ;
458
- output = output . Where ( t => IsMatch ( t , "Name" , pattern ) ) ;
459
- }
460
- }
461
-
462
- return output . ToList ( ) ;
439
+ return TopLevelWildcardFilter ( null , name , resources ) ;
463
440
}
464
441
465
442
private bool HasProperty < T > ( string property )
0 commit comments