Insert or Reorder Builder Strategies

Topics: CAB & Smart Client Software Factory
Aug 23, 2007 at 8:24 PM
Hi, all. Does anyone know how to reorder the builder strategies? My goal is to create a generic type mapping strategy that uses a naming convention to map a view interface to a view implementation.

Here's what I've looked at and tried so far:
I read an article by Mark Seeman on how to use an ITypeMappingPolicy to map one discrete type to another. That article is here: . I don't like that because I don't want to add a type mapping policy for every view in my application. I want to add one strategy that if you ask for an IFoo view will find a Foo type from a configured view implementation assembly and build it up.

I created a custom BuilderStrategy that behaved this way and added it to the builder's strategy list for the PreCreation stage in the AddBuilderStrategies override of my SmartClientApplication. The problem with this, however, is property injection no longer works. I'm assuming that is why I see the TypeMappingStrategy being added first in the Builder ctor.

There appears to be no Insert on the strategy list so I cannot add my strategy toward the head of the chain for the appropriate stage. The best I can come up with is to create a temporary strategy list, add my strategy to the head for PreCreation, iterate over the other strategies in the Builder and add them to my temp list, clear the strategy list and add everything back in the right order. This won't work however, because once you add something to the strategy list the stage that it belongs in is long gone so I cannot add to the temp list.

I could just clear the list and add all the strategies I know (via Reflector) should be in there in the right stages but that seems like a really bad smell.

Anybody have any ideas?