ChrisMissal / Formo

Formo allows you to use your configuration file as a dynamic object. Turn your web.config or application settings into a rich, dynamic object.
http://chrismissal.com/Formo/
MIT License
259 stars 33 forks source link

Support configuration sources other than System.ConfigurationManager #5

Closed dontjee closed 11 years ago

dontjee commented 11 years ago

Windows Azure applications use CloudConfigurationManager instead of System.ConfigurationManager to read configuration values. It would be nice if there was a way to inject a different setting provider (like the Azure one) to be used with Formo. It would also allow for mocking out config values in unit tests.

I'd be happy to help provide a pull request, I'm just not sure how you'd like the code to be structured. This feature could be accomplished via an interface and injected into the Formo Configuration object at some point. There could also be multiple versions of the Formo package, one for regular configuration manager, one for Azure, etc.

ChrisMissal commented 11 years ago

Here's what I'm thinking:

The Configuration class just drops the "Manager" part. What about a CloudConfiguration class? The GetValue(string name) method could be changed to virtual protected and drop the static. Then have CloudConfiguration override that method?

Just thinking out loud at this point.

dontjee commented 11 years ago

Yup I think that could definitely work. Biggest problem I see is introducing the dependency on the WindowsAzure.Configuration nuget package. It's going to be unnecessary for the majority of people using Formo.

ChrisMissal commented 11 years ago

Good point. A separate Project (and NuGet package) could live alongside. I want to keep "base" Formo dependency free.

ChrisMissal commented 11 years ago

Here's a branch with the cloud project: https://github.com/ChrisMissal/Formo/tree/cloud - thoughts?

dontjee commented 11 years ago

Code looks right to me, you beat me to it :smile:

Should it reference Formo via nuget instead of a project reference? That way the Formo.Cloud package has a dependency on Formo. The way it is now it's a project reference, and I'm not sure the nuget package for Formo.Cloud would work.

ChrisMissal commented 11 years ago

Good catch! I'll get that fixed.