Skip to content

Commit

Permalink
Merge pull request #1674 from SimonCropp/Resources
Browse files Browse the repository at this point in the history
cleanup Resources
  • Loading branch information
josephdecock authored Jan 28, 2025
2 parents f753fe1 + 2ebb39c commit b4daf0a
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions identity-server/src/Storage/Models/Resources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public class Resources
/// </summary>
public Resources()
{
IdentityResources = new HashSet<IdentityResource>();
ApiResources = new HashSet<ApiResource>();
ApiScopes = new HashSet<ApiScope>();
}

/// <summary>
Expand All @@ -37,20 +40,11 @@ public Resources(Resources other)
/// <param name="identityResources">The identity resources.</param>
/// <param name="apiResources">The API resources.</param>
/// <param name="apiScopes">The API scopes.</param>
public Resources(IEnumerable<IdentityResource> identityResources, IEnumerable<ApiResource> apiResources, IEnumerable<ApiScope> apiScopes)
public Resources(IEnumerable<IdentityResource>? identityResources, IEnumerable<ApiResource>? apiResources, IEnumerable<ApiScope>? apiScopes)
{
if (identityResources?.Any() == true)
{
IdentityResources = identityResources.ToHashSet();
}
if (apiResources?.Any() == true)
{
ApiResources = apiResources.ToHashSet();
}
if (apiScopes?.Any() == true)
{
ApiScopes = apiScopes.ToHashSet();
}
IdentityResources = identityResources?.ToHashSet() ?? new HashSet<IdentityResource>();
ApiResources = apiResources?.ToHashSet() ?? new HashSet<ApiResource>();
ApiScopes = apiScopes?.ToHashSet() ?? new HashSet<ApiScope>();
}

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

/// <summary>
/// Gets or sets the API resources.
/// </summary>
public ICollection<ApiResource> ApiResources { get; set; } = new HashSet<ApiResource>();
public ICollection<ApiResource> ApiResources { get; set; }

/// <summary>
/// Gets or sets the API scopes.
/// </summary>
public ICollection<ApiScope> ApiScopes { get; set; } = new HashSet<ApiScope>();
public ICollection<ApiScope> ApiScopes { get; set; }
}

0 comments on commit b4daf0a

Please sign in to comment.