Created
March 16, 2018 09:09
-
-
Save pietrom/975019ad5e684d8e08b887baeca10cc3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| using System; | |
| using System.Collections.Specialized; | |
| using System.Configuration; | |
| public static class ConfigurationExtension { | |
| public static string ReadSetting(this NameValueCollection self, string key) { | |
| return self[$"{Environment.MachineName}.{key}"] ?? self[key]; | |
| } | |
| public static string ReadConnectionString(this ConnectionStringSettingsCollection self, string name) { | |
| return self[$"{Environment.MachineName}.{name}"]?.ConnectionString ?? self[name]?.ConnectionString; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment