In the first post of this 2 part series, we looked at a class named Syntax
designed to be a pattern allowing for the easy creation and maintenance of a Fluent API. In the second post, we’ll explore what it takes to extend and implement that pattern. [More]
I’ve been a fan of Fluent APIs for a considerably long time now, and given their rise in popularity over the past few years I’m clearly not alone. There are several approaches one can take to creating their own fluent API, each with their own pitfalls and merits. In this 2 part series, we’ll take a look at an approach that I’ve been using that attempts to simplify the creation of Fluent APIs.
[More]
Last week a co-worker and I had a disagreement on the implications of using .GetType() -- is it reflection or not?
Turns out I was both right and wrong about this...
[More]
One of the coolest features of C# 3.0 is Extension Methods. Basically, an extension method is a static method that can extend a given type (even if that type is closed). The following extension method adds a .ValidateRegularExpression() method to the String object.
public static bool ValidateRegularExpression(this string validationData, string regularExpression)
if (!IsBlank(validationData))
{
System.Text.RegularExpressions.Regex re;
try
{
re = new System.Text.RegularExpressions.Regex(regularExpression);
return re.IsMatch(validationData);
}
catch (System.Exception)
{
return false;
}
finally
{
re = null;
}
}
return false;
}
There's always been some confusion for developers on things like naming conventions, coding style, when/where/how to use namespaces, and the like. Microsoft published guidelines for this 3 or so years back and updates them as new releases of .Net come out. You may find them online at:
http://msdn2.microsoft.com/en-us/library/ms229042.aspx