Created
September 5, 2013 03:33
-
-
Save ljinke/6445760 to your computer and use it in GitHub Desktop.
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
/// <summary> | |
/// Used for configuration when different user use different settings e.g. db connection string | |
/// </summary> | |
public static class ConfigurationUtil | |
{ | |
static NameValueCollection appSettings = ConfigurationManager.AppSettings; | |
static ConnectionStringSettingsCollection connectionStrings = ConfigurationManager.ConnectionStrings; | |
public static string GetAppSetting(string name) | |
{ | |
string tmpName = string.Format(@"{0}\{1}", System.Environment.MachineName, name); | |
string tmpValue = appSettings[tmpName]; | |
if(string.IsNullOrEmpty(tmpValue)) | |
{ | |
tmpValue = appSettings[name]; | |
} | |
return tmpValue; | |
} | |
public static string GetConnectionStrings(string name) | |
{ | |
string tmpName = string.Format(@"{0}\{1}", System.Environment.MachineName, name); | |
var tmpValue = connectionStrings[tmpName]; | |
if (tmpValue==null) | |
{ | |
tmpValue = connectionStrings[name]; | |
} | |
return tmpValue.ConnectionString; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment