-
Notifications
You must be signed in to change notification settings - Fork 494
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code changes to sync up with cosmos.direct release 3.31.2.
- Loading branch information
1 parent
d22ccdf
commit 949ce0d
Showing
8 changed files
with
381 additions
and
97 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
Microsoft.Azure.Cosmos/src/direct/Azure.Core/AppContextSwitchHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
//------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//------------------------------------------------------------ | ||
|
||
// This File is copied from Azure.Core repo i.e. https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/src/Shared/AppContextSwitchHelper.cs | ||
|
||
#nullable enable | ||
#if NETSTANDARD2_0_OR_GREATER | ||
namespace Azure.Core | ||
{ | ||
using System; | ||
/// <summary> | ||
/// Helper for interacting with AppConfig settings and their related Environment variable settings. | ||
/// </summary> | ||
internal static class AppContextSwitchHelper | ||
{ | ||
/// <summary> | ||
/// Determines if either an AppContext switch or its corresponding Environment Variable is set | ||
/// </summary> | ||
/// <param name="appContexSwitchName">Name of the AppContext switch.</param> | ||
/// <param name="environmentVariableName">Name of the Environment variable.</param> | ||
/// <returns>If the AppContext switch has been set, returns the value of the switch. | ||
/// If the AppContext switch has not been set, returns the value of the environment variable. | ||
/// False if neither is set. | ||
/// </returns> | ||
public static bool GetConfigValue(string appContexSwitchName, string environmentVariableName) | ||
{ | ||
// First check for the AppContext switch, giving it priority over the environment variable. | ||
if (AppContext.TryGetSwitch(appContexSwitchName, out bool value)) | ||
{ | ||
return value; | ||
} | ||
// AppContext switch wasn't used. Check the environment variable. | ||
string? envVar = Environment.GetEnvironmentVariable(environmentVariableName); | ||
if (envVar != null | ||
&& (envVar.Equals("true", StringComparison.OrdinalIgnoreCase) | ||
|| envVar.Equals("1", StringComparison.OrdinalIgnoreCase))) | ||
{ | ||
return true; | ||
} | ||
|
||
// Default to false. | ||
return false; | ||
} | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.