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

Provide ability to get section as enumeration #17

Closed ChrisMissal closed 11 years ago

ChrisMissal commented 11 years ago

Given a custom section, I would like to obtain a set of types for the entire section. The usage should look like this:

dynamic config = new Configuration("myFoos");
IEnumerable<Foo> foos = config.BindAll<Foo>();

and

dynamic config = new Configuration("myFoos");
IEnumerable<Foo> foos = config.BindAll<Foo>((k, v) => new Foo { Key = k, Value = v });

Or something similar.

ChrisMissal commented 11 years ago

Created it to work like so:

Configuration config = new Configuration("userSection");
var users = config.BindPairs<User, int, string>(x => x.ID, x => x.Name);

Contrived example, but works for tests.