0

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"]; }
    }

    ..............
}
user3691221
  • 109
  • 2
  • 13

2 Answers2

1

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.

Oluwafemi
  • 14,243
  • 11
  • 43
  • 59
  • Ok, so I could create Infrastructure project and move it there. – user3691221 Jun 22 '15 at 11:31
  • 1
    Most definitely. Its a lot better because you might have to create other classes that are needed across layers and then you can update your class library project approriately. – Oluwafemi Jun 22 '15 at 11:33
  • If this class is only reading values from `web.config`, I suggest you remove the `Interface` and make it a `static class` – Oluwafemi Jun 22 '15 at 11:37
0

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.

Jure
  • 1,156
  • 5
  • 15