Rico Suter's blog.
 

Articles

Post-process the HTML output of an action in ASP.NET MVC

This article shows how to implement a post-processor for an ASP.NET MVC application, which transforms the output of an controller action before it is transmitted to the client. The obvious way to do this is by implementing a custom action filter. First, we implement the base filter class:
Read More ›

Manually triggered computed observables in KnockoutJS

In KnockoutJS I sometimes need to create a computed observable which does not automatically detect the dependencies and which has to be triggered manually. This may be required if the computation is very complex and should only run in certain situations.
Read More ›

ASP.NET MVC: How to implement an edit form for an entity with a sortable child collection

This article shows how to implement the edit form for an entity with a collection property. As a show case, we will implement the edit form for a person entity with multiple addresses. The following diagram shows the UML diagram of the two entity classes:
Read More ›

My most used Visual Studio and ReSharper extensions

This article describes some of the Visual Studio and ReSharper extensions and development tools I’m using to enhance my daily C#/.NET development productivity.
Read More ›

Cheat Sheet: Best practices for writing XML documentation in C#

The XML documentation tags of C# are described very well in the MSDN. However, the article does not explain how the contained phrases and sentences should be written. This article tries to fill this gap by providing rules and some sample phrases.
Read More ›

How to implement and register a custom dependency resolver in ASP.NET MVC 5

The ASP.NET MVC 5 framework supports the integration of 3rd party dependency injection frameworks. This can be done by implementing the IDependencyResolver interface and registering an instance of the interface on application startup. The registration is made in the Application_Start method which can be found in the Global.asax.cs file:
Read More ›

Elegant method parameter validation with Code Contracts support

Each C# developer knows the drill: Each method parameter has to be validated against null values, wrong value ranges or other contract constraints. When also validating using Code Contracts, the resulting code may take up most of the method body:
Read More ›

A transparent undo/redo mechanism for XAML applications

In one of my recent projects, I had to implement an undo/redo mechanism for an observable object graph. The usual approach to this problem is to implement commands which operate on the object graph and provide Do() and Undo() methods. The problem was, that a great portion of the business logic was already implemented and was not command-based. This is why I had to find a solution which works transparently on the property change events of an object graph whose objects implement the INotifyCollectionChanged interface and use the ObservableCollection class for collection properties.
Read More ›

Recommendations and best practices for implementing MVVM and XAML/.NET applications

In this article I’ll describe the rules and practices I’m following for XAML and MVVM application development. I’m using the described techniques since multiple years and they have proven themselves for me. Most of the described rules apply for all types of XAML projects – Windows Store, Windows Phone, Silverlight and WPF projects.
Read More ›

How to mimic singlecast events in C#

C# only supports multicast events and delegates. Even if you define a delegate property without the event keyword, it still remains multicasted:
Read More ›