Skip to content

Commit b4daf0a

Browse files
authored
Merge pull request #1674 from SimonCropp/Resources
cleanup Resources
2 parents f753fe1 + 2ebb39c commit b4daf0a

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

identity-server/src/Storage/Models/Resources.cs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ public class Resources
1919
/// </summary>
2020
public Resources()
2121
{
22+
IdentityResources = new HashSet<IdentityResource>();
23+
ApiResources = new HashSet<ApiResource>();
24+
ApiScopes = new HashSet<ApiScope>();
2225
}
2326

2427
/// <summary>
@@ -37,20 +40,11 @@ public Resources(Resources other)
3740
/// <param name="identityResources">The identity resources.</param>
3841
/// <param name="apiResources">The API resources.</param>
3942
/// <param name="apiScopes">The API scopes.</param>
40-
public Resources(IEnumerable<IdentityResource> identityResources, IEnumerable<ApiResource> apiResources, IEnumerable<ApiScope> apiScopes)
43+
public Resources(IEnumerable<IdentityResource>? identityResources, IEnumerable<ApiResource>? apiResources, IEnumerable<ApiScope>? apiScopes)
4144
{
42-
if (identityResources?.Any() == true)
43-
{
44-
IdentityResources = identityResources.ToHashSet();
45-
}
46-
if (apiResources?.Any() == true)
47-
{
48-
ApiResources = apiResources.ToHashSet();
49-
}
50-
if (apiScopes?.Any() == true)
51-
{
52-
ApiScopes = apiScopes.ToHashSet();
53-
}
45+
IdentityResources = identityResources?.ToHashSet() ?? new HashSet<IdentityResource>();
46+
ApiResources = apiResources?.ToHashSet() ?? new HashSet<ApiResource>();
47+
ApiScopes = apiScopes?.ToHashSet() ?? new HashSet<ApiScope>();
5448
}
5549

5650
/// <summary>
@@ -64,15 +58,15 @@ public Resources(IEnumerable<IdentityResource> identityResources, IEnumerable<Ap
6458
/// <summary>
6559
/// Gets or sets the identity resources.
6660
/// </summary>
67-
public ICollection<IdentityResource> IdentityResources { get; set; } = new HashSet<IdentityResource>();
61+
public ICollection<IdentityResource> IdentityResources { get; set; }
6862

6963
/// <summary>
7064
/// Gets or sets the API resources.
7165
/// </summary>
72-
public ICollection<ApiResource> ApiResources { get; set; } = new HashSet<ApiResource>();
66+
public ICollection<ApiResource> ApiResources { get; set; }
7367

7468
/// <summary>
7569
/// Gets or sets the API scopes.
7670
/// </summary>
77-
public ICollection<ApiScope> ApiScopes { get; set; } = new HashSet<ApiScope>();
71+
public ICollection<ApiScope> ApiScopes { get; set; }
7872
}

0 commit comments

Comments
 (0)