From b505fe07d6223e22687555a4c599e1fc800f2bd3 Mon Sep 17 00:00:00 2001 From: Christopher Granade Date: Thu, 30 Jul 2020 11:43:58 -0700 Subject: [PATCH] Make GetOptionOrDefault public. --- src/Jupyter/ConfigurationSource.cs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Jupyter/ConfigurationSource.cs b/src/Jupyter/ConfigurationSource.cs index 3ded3daaa3..ba0d2b7630 100644 --- a/src/Jupyter/ConfigurationSource.cs +++ b/src/Jupyter/ConfigurationSource.cs @@ -32,7 +32,27 @@ public interface IConfigurationSource /// void Persist(); - private T GetOptionOrDefault(string optionName, T defaultValue) => + /// + /// 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. + /// + /// + /// Name of the option to be retrieved. + /// + /// + /// Value to be returned when the option specified by + /// has not been set. + /// + /// + /// The expected type of the given option. + /// + /// + /// The value of the option specified by + /// if it exists, otherwise + /// the value of . + /// + public T GetOptionOrDefault(string optionName, T defaultValue) => Configuration.TryGetValue(optionName, out var token) ? token.ToObject() ?? defaultValue : defaultValue;