Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
Merged
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
22 changes: 21 additions & 1 deletion src/Jupyter/ConfigurationSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,27 @@ public interface IConfigurationSource
/// </summary>
void Persist();

private T GetOptionOrDefault<T>(string optionName, T defaultValue) =>
/// <summary>
/// Given the name for a configuration and a default value,
/// returns the given option if it exists, or the default if the
/// user has not specified that option.
/// </summary>
/// <param name="optionName">
/// Name of the option to be retrieved.
/// </param>
/// <param name="defaultValue">
/// Value to be returned when the option specified by
/// <paramref name="optionName" /> has not been set.
/// </param>
/// <typeparam name="T">
/// The expected type of the given option.
/// </typeparam>
/// <returns>
/// The value of the option specified by
/// <paramref name="optionName" /> if it exists, otherwise
/// the value of <paramref name="defaultValue" />.
/// </returns>
public T GetOptionOrDefault<T>(string optionName, T defaultValue) =>
Configuration.TryGetValue(optionName, out var token)
? token.ToObject<T>() ?? defaultValue
: defaultValue;
Expand Down