Tag Archives: Projects

Personal, non-work related projects. Think of simple prototypes, proof of concepts and open source thingies.


LocalStorage for .NET

It happened once too often. For the last time I wrote another helper class that serialized<>deserialized some stuff to the filesystem, just so it could be restored in a new debug session. “What a bless localStorage for Javascript is…”, I thought to myself. And with that thought, I started to work on LocalStorage for .NET.

LocalStorage is an extremely lightweight, dependency-less library with a simple concept: allow any .NET object to be stored in an in-memory store – and allow it to be persisted to filesystem. It serves the purpose of filling the gap where most in-memory caches, or key/value stores, are too complex or require either an install or some sort of tedious configuration before you can start coding.

LocalStorage for .NET is inspired by – but totally unrelated to – Javascript’s localStorage; a temporary caching lib for low-demanding data needs.


If you want to get started fast, simply install the library through NuGet:

$ Install-Package LocalStorage

I’ve made some effort to describe the how-and-what in detail in the README of the project, along with a bunch of examples, but let me oversimplify its use with the following sample:

// initialize a new instance
// (see the README for more configurable options)
using (var storage = new LocalStorage()) 
    // store any object
    var weapon = new Weapon("Lightsaber");
    storage.Save("weapon", weapon);

    // ... and retrieve the object back
    var target = storage.Get<Weapon>("weapon");

    // or store + get a collection
    var villains = new string[] { "Kylo Ren", "Saruman", "Draco Malfoy" };
    storage.Save("villains", villains);

    // ... and get it back as an IEnumerable
    var target = storage.Query<string>("villains");

    // finally, persist the stored objects to disk (.localstorage file)

Again, take a look at the GitHub repo for more in-depth information:

LocalStorage for .NET: it’s dead simple. It has no dependencies. It’s lightweight. And it’s got a memorable name, so hopefully you’ll consider giving it a go yourself someday.


ASP.NET MVC 5 Template for Xamarin Studio

Recently the latest version of Xamarin Studio has been released, along with Mono 3.4. And honestly, no one can deny that cross platform .NET development just keeps on getting better and better. I still see a great future for especially Mono if the open source community and the people at Xamarin manage to keep their current pace of improvements. #kudos++

Although with every update of both Xamarin and Mono the bar is set higher, some fields of interest seem to be lacking to get updated. Clearly the mobile platforms, like iOS, Android and Windows Phone seem to get all the attention. But the web platform seems to lose focus in the Xamarin/Mono tagteam, especially ASP.NET.

For example, the native template for ASP.NET is still set to version 3. Which was the non-MyGet version, if you remember. And that means b*tchy to update and cumbersome to update to recent versions. However, it is still possible to actually run and debug new ASP.NET MVC sites on Mono.

To this end, I’ve created a simple and clean setup for a Xamarin project that allows you to run an ASP.NET MVC 5.1 site on Mac OSX. In short:

Fork it on GitHub

Grab a fresh copy from the git repo and you’ll get:

  • A clean ASP.NET MVC 5 application with RAZOR support
  • Can be run entirely from Xamarin Studio on Mac OSX
  • Can be updated and extended through NuGet
  • It just works…

Known Issues

Do note that an Empty ASP.NET MVC 5 project created in Visual Studio won’t run by default in Xamarin. You have to plumb a bit here and there. If you’re curious on what you need to do to make things blend on Xamarin Studio on Mac, take a look at the changes I’ve made in the repo.

Tip: Want to reproduce it yourself? All required changes to run ASP.NET MVC 5 on Mac are neatly documented as seperate commits.

To summarize these changes, the current limitations for a clean setup seems to be:

  • App relative paths don’t work, e.g. using tildes like ~/assets/style.css
  • The view’s web.config has teh disabled
  • Mono currently supports .NET 4.5, not 4.5.1
  • routes.LowerCaseUrls isn’t supported (yet)
  • System.Web.Entity reference isn’t supported (yet)