Tech Blog

Jay's Technical blog

My Library Port Releasing Continues: AutoMapper and Castle.Core for WP7

30 September 2010
Jay Kimble

[WARNING! This is an archived post and as such there may be things broken/missing here.. you have been warned.]


Consider these ports are a starting point if you need these libraries. I am delivering them together because Castle.Core is a dependency of AutoMappers. I did not port tests because before I was done the internal (company) library I wanted to get running removed its dependency on Automapper. I’m really releasing this in case someone needs it.

Castle.Core does contain some of the pieces of the DynamicProxy, but not many, and porting it is not going to be possible until WP7 gets Reflection.Emit libraries (actually it’s not even possible to port any other implementation of Reflection.Emit, so don’t bother trying.. trust me I have.. it’s locked down).

These are both on my SkyDrive.
jbogard-AutoMapper-8cdd67f-src with

PowerCollections and C5 Collections for Silverlight4

20 September 2010
Jay Kimble

[WARNING! This is an archived post and as such there may be things broken/missing here.. you have been warned.]

I have been doing a lot of “hobby” porting over the last couple months. By that I mean that I have done a lot of porting of projects (mostly to WP7, but in some cases I’m porting to Silverlight 4). I just recently decided that I really need to start releasing this stuff (on my blog at first but then later I will start submitting this stuff back to the original projects).

First up are two libraries of extended Collections: the Wintellect Power Collections for .NET, and the C5 Generic Collection Library for C#. Both contain a large number of enhanced collections. Check out the documentation on each.

Wintellect Power Collections

With the Power Collections I ported the test suite that goes with it to see how my port went. I am currently passing 628 of the 650 test. The 22 tests that aren’t passing all have to do with serialization This is mostly due to the fact that there isn’t a good replacement for Binary Serialization (BinaryFormatter) in Silverlight. I have tried numerous available Open Source serialization schemes but in the end I decided just to release this getting into folk’s hands (I’m pretty sure that it should work, but haven’t had a chance to fully prove that with my tests).

Here's the zipped solution and files:Wintellect Power

C5 Collections

Next is the excellent C5 Collections Library. I also ported the test suite for this. There are 1422 tests in the suite of which this port is passing 1404 (only 18 fail). Like the PowerCollections, the tests that are failing all have something to d with serialization.

Here's the zipped solution and files:C5

An MVVM Light T4 template to auto build your ViewModelLocator

13 September 2010
Jay Kimble

[WARNING! This is an archived post and as such there may be things broken/missing here.. you have been warned.]

A few weeks ago I tweeted that I had built a T4 template for auto-building your ViewModelLocator class After using it for a bit I have decided to finally release to more than just Laurent Buigion.

You will need to do a little bit of customization for each project. Take a look at lines 28-35

  1:string LocatorsNameSpace = "Namespace"; // This is the Namespace that your locator will appear. This is typically {AppName}.Views
  2:string LocatorClassName = "ViewModelLocator"; // This is the name of your locator class (this is the standard name)
  3:  vmsToExclude = new typeRef[] {
  4://new { typeName="MainViewModel"}   // Add entries here to exclude classes from your locator
  5:  };
  6:  baseClassNames = new typeRef[] {
  7:new typeRef{ typeName="GalaSoft.MvvmLight.ViewModelBase"}, // Add the base type(s) that your viewmodel's inherit from
  8:  };

I think this is pretty self-explanatory, but you need to –at the very least—set the namespace of the locator class.You might optionally want to change the location class’ name.

Lines 30-32 (3-5 above) let you override and tell the template to ignore certain classes.

Lines 33-35 (6-8 above) let you tell the engine what the parent class is of your ViewModels. If you are using MVVM Light then this should be correct. If you have your own parent class then you will want to use that instead.

This T4 template doesn’t currently search assemblies. Eventually I will do that, but for most of my work, the ViewModels are in my code and compiled with the project.

If you install the Chirpy addin, you can forget about the locator’s generation entirely as Chirpy will automatically run your T4 templates every compile.

Oh yeah, here’s the file