Skip to content

Commit

Permalink
Add method for registering SSB codelists with override options contro…
Browse files Browse the repository at this point in the history
…lling the mapping to description and help texts
  • Loading branch information
Ronny Birkeli committed May 16, 2023
1 parent 247aafb commit 2a92ef4
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Altinn.Codelists/SSB/Extensions/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,20 @@ public static IServiceCollection AddSSBClassificationCodelistProvider(this IServ

return services;
}

/// <summary>
/// Adds the specified classification based on the known classification id. If it is an id mapped to the <see cref="Classification"/> enum
/// the correct enum will be set, otherwise Custom will be used as enum value but the id will be sent to the underlying api.
/// </summary>
/// <param name="services">The <see cref="IServiceCollection"/> to add to</param>
/// <param name="id">The codelist id</param>
/// <param name="classificationId">The id of the classification to return</param>
/// <param name="options"><see cref="ClassificationOptions"/> allowing control over how data maps from the source to the app options</param>
/// <param name="defaultKeyValuePairs">Default set of key/value pairs to be used. Will be overriden by matching qyery parameters runtime.</param>
public static IServiceCollection AddSSBClassificationCodelistProvider(this IServiceCollection services, string id, int classificationId, ClassificationOptions options, Dictionary<string, string>? defaultKeyValuePairs = null)
{
services.AddTransient<IAppOptionsProvider>(sp => new ClassificationCodelistProvider(id, classificationId, sp.GetRequiredService<IClassificationsClient>(), defaultKeyValuePairs, options));

return services;
}
}

0 comments on commit 2a92ef4

Please sign in to comment.