Home » .NET (page 20)

.NET

Simple WCF SOAP-REST Multi-Project Template

Download the source code for this post. I did it again: another multi-project Visual Studio template – this time for a simple WCF service that exposes both SOAP and REST endpoints. My other REST and SOAP templates are intended as a starting point for more real-world WCF services. However, what I often need is a starting point for building a ...

Read More »

How to handle transactions in ASP.NET MVC3

I got annoyed about having to repeat the transaction handling in every POST method of my controllers. First of all: I don’t want to have to take the unit of work in the constructor of each controller, since that implicitly says that all/most methods uses transactions. And I do not want to have to resolve a factory, since that says ...

Read More »

Validate User Input, Not Developer Input

I have a very simple rule, I like to follow that helps to simplify my code. “Don’t validate developer input” This rule simply means that we should not try and validate input that came from a source that is not a user or external system. Another way to put it would be, don’t validate parameters you pass around in your ...

Read More »

WCF Rest Services for Windows Phone

So great, to create WCF Rest services for Windows Phone, you have to follow just 5 steps. This post will have more code than words, making it neat and to-the-point Step 1: Create a WCF Service Define the interface IMyService in ‘Services’ folder of YourWebsite namespace YourWebsite.Services { [ServiceContract(Namespace = "http://YourWebsite.com/services", Name = "MyService")] public interface IMyService { [OperationContract(Name="DoWork")] [WebGet(UriTemplate ...

Read More »

Roll Your Own REST-ful WCF Router

Recently I’ve been tasked with building a WCF routing service and faced the choice of whether to go with the built-in router that ships with WCF 4.0, or to build one from scratch. The built-in router is great for a lot of different scenarios – it provides content-based routing, multicasting, protocol bridging, and failover-based routing. However, as the MSDN documentation ...

Read More »

C# text file deduping based on trimmed lines

A while ago, I needed to analyze a bunch of files based on the unique trimmed lines in them. I based my code on the C# Tee filter and the StackOverflow example of C# deduping based on split. It is a bit more extensive than strictly needed, as it has a few more commandline arguments that come in handy when ...

Read More »

Inversion of control containers – Best practices

Disclaimer: I’ve used IoC containers for a couple of years now and also made a couple of my own (just to learn, nothing released). I’ve also consumed loads of documentation in the form of blogs and stackoverflow questions. And I thought that I should share what I’ve learned. In other words: These are my very own subjective best practices. An ...

Read More »

CInject – Code Inject

CInject (or CodeInject) allows code injection into any managed assembly without disassembling and recompiling it. It eases the inevitable task of injecting any code in single or multiple methods in one or many assemblies to intercept code for almost any purpose. When using CInject, you do not require any knowledge of the target application. You can create your own injectors ...

Read More »

Why you need to make your tests fail

Test Driven Development (TDD) have many benefits. For start it’s a design methodology that help avoiding “Analysis paralysis” and make sure that you only have the needed code to solve a problem. Yesterday I found another benefit of writing the tests before the code – you get to see them fail! A while back I wrote about another shortcoming of ...

Read More »

Creating robust tests with Isolator V7

The problem with unit tests is that they keep on breaking…  Obviously that’s not entirely correct, nevertheless I had the pleasure of hearing the sentence above numerous times. It’s true – unit tests do tend to fail and we prefer that they fail only when a regression occurs – when something that used to work stopped working, because that’s the ...

Read More »