Richard's Blog

  • Custom XML model binder for ASP.NET MVC

    In an earlier post I wrote about using an XML value provider to allow you to send XML to your .NET MVC action methods. This is great, until you want to accept XML where you have a model that needs XML attributes to control how it's deserialized. As the value provider stage happens before model binding it has no knowledge of the model objects that the values will be pushed into. So it can't look at your model class's XML attributes.

    In cases like this, you're better of using a custom XML model binder.

    To setup an XML model binder you need to create a model binder and a model binder provider. …

  • Mocking with NSubstitute

    My previous C# mocking framework of choice was MOQ. It's very powerful and fairly easy to use, but I recently started using NSubstitute and fell in love with how easy and intuitive it was to use.

    The cleverest part is that unlike MOQ the mocks produced actually implement the interface they're mocking and this makes the code much clearer and a little bit shorter.

    Here is a very simple example:

    var mockThing = Substitute.For<IThing>();

    mockThing.DoThingy().Returns("Something");

    // Use mock thing

    UseThing(mockThing);

    In MOQ this is also quite straightforward but the setup code to change …

  • Record breaking fonts on vinyl

    Font Sunday is a weekly twitter phenomena where the typographically obsessed share examples of fonts around them. The theme this week was 'Fonts on Vinyl' and this turned out to be a theme that got people excited and it was the most contributed to week we've ever had.

    The Design Museum started Font Sunday and set the theme each week. I help out by collating the contributions on a Pinterest board.

  • The Side Project Startup reading list

    This is the reading list for my talk, 'The Side Project Startup. I last gave this talk at DDD North 2 and it's slowly evolving every time I give it. If you're interested in side projects and starting your own small software business then this reading list is for you.

    Books

    The Lean Startup – Eric Ries

    If you've not heard of the Lean Startup or you're not convinced, then you should read this book. If you are convinced, then the next two books on this list actually go into detail you can start using today.

    Start small stay small – Rob Walling

    Blogs

    Sofware by Rob - Author of 'Start small …

  • Windows 8 Excellence Labs

    Font Picker at the entrance to Microsoft Reading

    Developing for a new platform, particularly one that's not finalised yet can come with a bit of a steep learning curve and a number of frustrating moments. It's also exciting and I can't wait for Windows 8 to come out and for my app Font Picker to be available in the new Windows Store. Something that has blown me away has been the support from Microsoft. The documentation is great, there have been roadshows and you could even get one on one time with a Microsoft engineer to fine tune your app and get it ready for the store. These were the slightly cheesily named 'Excellence Labs'.

    The …

  • WinRT GridView with inline group headers and semantic zoom

    My Windows 8 app had a GridView with grouped content and also made nice use of semantic zoom to make navigating between those groups easy. All I wanted to do was to make the headers appear in the content like the People App. I thought this would be a simple case of finding the right container template to use, but after reading this post by Mike Taulty it turns out that using the group style built into GridView can't do this. His post goes into a lot of detail about how to figure out your XAML and shows a GridView with inline group headers. I've taken his method and extended it to include …

  • XAML Spy is Firebug for XAML

    I have a love hate relationship with XAML. XAML gives you a lot of control over layout, but it's often hard to tell what's going on. When your layouts rely on data I found the design tools in Visual Studio lacking. I got into a very time consuming workflow of: build app and review interface, tweak XAML, rebuild app and review interface again.

    XAML Spy is a tool that has helped me a lot in the same way that Firebug changed the way I developed HTML, XAML Spy has made my XAML development workflow a lot smoother.

    XAML Spy works with WPF, Silverlight and WinRT, but I've only used while developing …

  • Where are my application files in Windows 8

    If you install a Windows 8 store app the files don't get put exactly where you expect them to be.

    App files

    \Program files\WindowsApps\[company].[application name]_[version]_[random letters]

    App storage

    [User directory]\AppData\Local\Packages\[company].[application name]_[random letters]

    App manifest

    \ProgramData\Microsoft\Windows\AppRepository\[company].[application name]_[version]_[random letters].xml

  • Living off the long tail

    A long tail

    What is the long tail

    In his original post and the following book The Long Tail Chris Anderson explains the modern economic phenomenon of the long tail. Selling goods through the web, particularly digital goods is offering the consumer an alternative to the hit driven culture of the past:

    Forget squeezing millions from a few megahits at the top of the charts. The future of entertainment is in the millions of niche markets at the shallow end of the bitstream.

    The basic premise is that in the past a shop could only carry so much stock. In a physical shop space is limited and also costs rent. …

  • Leeds Sharp

    Last night was the first Leeds# Microsoft Developer's User Group. Matt Ross and I have been wondering for a while why there were no .NET user groups near us and we decided to stop wondering and talking about it and just start one.

    The idea is that by joining forces with other local developers we can all become smarter and make some new friends. At our first meeting we had an interesting mix of people working on .NET projects involving a range of things from cows to parts for planes. We want to make sure that we respond to what the group wants and that's why we've set up a range of ways to …