/// <summary> /// Generates a key-per-file map of the options. /// </summary> /// <remarks> /// Each key is the file name; each value is the file content. /// </remarks> public static IDictionary <string, string> ToKeyPerFileConfiguration(this RootOptions options) { Dictionary <string, string> variables = new(StringComparer.OrdinalIgnoreCase); MapObject(options, string.Empty, variables); return(variables); }
/// <summary> /// Generates an environment variable map of the options. /// </summary> /// <remarks> /// Each key is the variable name; each value is the variable value. /// </remarks> public static IDictionary <string, string> ToEnvironmentConfiguration(this RootOptions options) { Dictionary <string, string> variables = new(StringComparer.OrdinalIgnoreCase); MapObject(options, "DotNetMonitor_", variables); return(variables); }
/// <summary> /// Sets API Key authentication. /// </summary> public static RootOptions UseApiKey(this RootOptions options, string algorithmName, byte[] apiKey) { if (null == options.ApiAuthentication) { options.ApiAuthentication = new ApiAuthenticationOptions(); } using var hashAlgorithm = HashAlgorithm.Create(algorithmName); options.ApiAuthentication.ApiKeyHash = ToHexString(hashAlgorithm.ComputeHash(apiKey)); options.ApiAuthentication.ApiKeyHashType = algorithmName; return(options); }