public IdentityServer4.Models.ApiResource ToModel() { return(new IdentityServer4.Models.ApiResource { ApiSecrets = ApiSecrets.Select(c => new IdentityServer4.Models.Secret { Type = c.Type, Description = c.Description, Expiration = c.Expiration, Value = StringExtensions.ToSha256(c.Value) }).ToList(), Description = Description, DisplayName = DisplayName, Enabled = Enabled, Name = Name, Properties = Properties, Scopes = Scopes.Select(s => new IdentityServer4.Models.Scope { Description = s.Description, DisplayName = s.DisplayName, Emphasize = s.Emphasize, Name = s.Name, Required = s.Required, ShowInDiscoveryDocument = s.ShowInDiscoveryDocument, UserClaims = s.UserClaims }).ToList(), UserClaims = UserClaims, }); }
/// <summary> /// Converts this class to IdentityServer4.Models.ApiResource /// </summary> /// <returns></returns> public IdentityServer4.Models.ApiResource ToApiResource() { var apiResource = this.CopyPublicPropertiesToNew <IdentityServer4.Models.ApiResource>(); //hidden properties need to be copied explicitly as dto utils will not matche them on type! if (UserClaims != null) { apiResource.UserClaims = UserClaims; } apiResource.ApiSecrets = ApiSecrets.Select(cs => new Secret(cs.Value.Sha256(), cs.Description, cs.Expiration)).ToList(); apiResource.Scopes = Scopes.Select(s => s.ToScope()).ToList(); return(apiResource); }