Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup Resources #1674

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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; }
}