Tuesday, September 13, 2016

Simplifying Condition-checking in C#

If you need to write a lot of "if" and "else" statements to check conditions in your code, then you definitely want to check out Cutting Edge Conditions!  https://conditions.codeplex.com/

Cutting Edge Conditions dramatically simplifies how to deal with condition checking throughout your code base using a Fluent API!

While Cutting Edge Conditions is a rather old library, it has been forked and is now being actively maintained on GitHub simply as "Conditions": https://github.com/ghuntley/conditions

You can download a NuGet package for Conditions from here: https://www.nuget.org/packages/Conditions/

One of the gaps in the code samples provided on the Conditions site, however, is the ability to display error messages when a particular condition is hit!

This can be simply be done by adding a description to the respective conditions as follows:

No comments:

Post a Comment