Make your code readable by making it flow with Generics

I’ve seen a couple of examples of code recently which basically have a method which work primarily on a base class but the resultant will always be cast to a concrete implementation. This can make the code a bit clunky as each caller has to cast the resultant to the type it’s expecting. Let me show you want I mean: public abstract class Base { public string Comment { get; set; } } public class Concrete : Base { } public class Update { public static Base AddComment(string message) { // the type created can be determined by some other means eg db call etc....

July 18, 2013 · 2 min

Debugging WCF messages before serialization

Over the past couple of weeks I’ve been doing a lot of work with WCF to do with the messages being sent between client and server and securely signing them. Signing the message isn’t the subject of this post however developing the following technique to see the message before it’s sent did lead me onto the solution for debugging messages being sent between client and server. This post is to show how you can intercept the message, update it once its been serialized into xml (or just look at the xml) but before it’s been sent to the server....

September 27, 2012 · 6 min