In the off-chance that I have to maintain your code in the future, I feel I should gamble and share this project with you. I created it, I use it, and I like it.
Something bothers me about seeing strings inside square brackets. It has always felt dirty and error-prone. Since C# is now being sucked into the universe of dynamic, I thought that was a good opportunity to use dynamic to avoid these strings. By no means does Formo fix all these issues, but it helps in a couple ways and makes me feel better when I need to reference configuration.
Given a configuration file:
Formo can be used to:
As well as:
Formo is lightweight, free to use, and has no dependencies. Use it now with NuGet:
Install-Package Formo
This covers the majority of use-cases I’ve come across. If you have improvements to Formo, or just ideas in general, please submit them as issues on the GitHub issues page.
Have an idea for a logo?! I’d love a pull request!
Oh hey, I'm a Senior Consultant for Headspring in Austin, TX. I've been working in software professionally since 2006 and I really, really love it. I'm mostly in the Microsoft world, but enjoy building computer things of all sorts (to be vague). When I'm not slinging code, I'm probably out and about slinging discs, bowling balls, or good beer with great friends.
What the difference between dynamic and magic strings ?
Mike
Square brackets and quotes
Rémi BOURGAREL
so ? the problem with magic stirng is not the color in visual studio or the notation, its problem is that it’s evaluated at runtime instead of compile time and you got the same problem with dynamics
http://chrismissal.lostechies.com Chris Missal
You’re completely correct. I wasn’t trying to solve that problem. This is *slightly* better IMO because of things like intellisense, fallback values, etc.
Askafif
where is intellisense for dynamics?
stimul8d
By Zeus’s beard, that’s a hot cup of tea!
http://realfiction.net Frank Quednau
Oh, looks like you built DynamicAppSettings anew :) check it out, it has some additional features, too, like nesting calls or indeed leveraging .NET Type conversion capabilities to get casts to other types
I didn’t show it, but when Configuration is created, the ctor can take in TypeConverters - https://github.com/ChrisMissal/Formo/blob/master/src/Formo/Configuration.cs#L14
I used to use a similar approach, but I didn’t like having to add properties. That’s when I started looking into this method. #hellaLazy
I’m sure I’ll have a different preference in another two years :)
afifmohammed
I have a similar implementation in configoo, except that I didn’t go the dynamics route as I didn’t see it any different to having strings. What I did add was support for unit testing and support to plug in any look up source. Also key values can be resolved using predicates. https://github.com/afifmohammed/configoo
Chris Stuff
Works atHeadspring Lives in Austin, TX Originally from Iowa Likes Bowling, Disc Golf and Comedy