SettingsProvider class - should it be in DAL or BLL project?

142 views Asked by At

I have in my application layers: Web, DAL and BLL.

Where should I place SettingsProvider class (to get values from web.config)? I think it should be inside DAL project. Am I right?

public class SettingsProvider : ISettingsProvider
{
    public string UploadImagesPath
    {
        get { return ConfigurationManager.AppSettings["UploadImagesPath"]; }
    }

    ..............
}
2

There are 2 answers

3
Oluwafemi On BEST ANSWER

I don't agree that there is a right layer for you to put that class since you reading values from the config file based on keys provided and it can be needed by one or all of the layers. In the case of all layers using this class, you can as well setup a common Class Library project and reference it in layers where it is needed.

0
Jure On

Since settings are specific to Web application (because they are defined in Web.config) I think you should put it in Web application and somehow "send" them to BLL or DAL, wherever appropriate. And since you already have an ISettingsProvider interface defined, you could make a use of some IoC container and registering this interface on Web's bootstrap method (or sth like that). Or just send your ISettingsProvider (maybe static variable) arround into DAL and BLL from Web application.