Friday, September 7, 2012

How can I expose my settings to other classes

How can I expose my settings to other classes

I have an application.

I login.

I make a web call and get a bunch of settings.

I publish an eventaggregator event that sends these settings to any other class that wants to listen and grab them.

To me this just seems like the wrong design. For a loosely coupled project what is the best way to share a bunch of settings in a class? I know I could make a static global, but that does not sound loosely coupled either!

Answers & Comments...

Answer: 1

You may define ISettingsProvider interface and use dependency injection and IoC containers like Unity or Autofac to inject this interface implementation to any class you would like to and use it there.
It will be loosely coupled because you will not have dependency to real setting provider implementation and it will be possible change implementation easily (e.g for unit testing).

by : petro.sidlovskyyhttp://stackoverflow.com/users/558711




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog