Skip to content

Instantly share code, notes, and snippets.

@pietrom
Created March 16, 2018 09:09
Show Gist options
  • Select an option

  • Save pietrom/975019ad5e684d8e08b887baeca10cc3 to your computer and use it in GitHub Desktop.

Select an option

Save pietrom/975019ad5e684d8e08b887baeca10cc3 to your computer and use it in GitHub Desktop.
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