I am currently building on my personal website. I use the Config global static class to store all the custom parameters that may be required for a change that is semi-global. So now it looks like this:
public static class Config
{
public static string ConnectionString = "mongodb://localhost";
public static MongoDB.Driver.MongoDatabase GetDB(){
MongoServer server = MongoServer.Create(Config.ConnectionString);
MongoDatabase db = server.GetDatabase(Config.Database);
return db;
}
public static Markdown GetMarkdown(){
var options=new MarkdownOptions(){
AutoHyperlink=true,
AutoNewlines=false,
EmptyElementSuffix=" />",
LinkEmails=false,
StrictBoldItalic=true
};
var m=new Markdown(options);
return m;
}
}
Does such a global configuration class use this anti-pattern? In addition, I prefer the connection strings to be outside of web.config. I like my web.config as little as possible.
source
share