tags:

views:

31

answers:

1

I remember .Net had a feature (don't remember whether it was a configuration option or assemby attribute) which would replace one class with another.

For example I have AmbiguousClass in some referenced assembly which uses locale-unaware strings. What I want to do is inherit AmbiguousClass with LocalizedAmbiguousClass and point to .Net that whenever AmbiguousClass is created or used a LocalizedAmbiguousClass should be used instead.

I remember something like that was mentioned in preparation for Microsoft 70-536 certificate

+1  A: 

I think that you're referring to the TypeForwardedToAttribute, but I don't think that this will achieve your goal, as you're creating a whole new type, instead of moving the same type to another assembly (or namespace).

If you're instantiating your 'AmbiguousClass' using a factory, then you have a single point in your code where you'll have to modify your code (because I think that this is really what you'll have to do). If you are not using some kind of factory, then I think you're facing a tough job. (Although Resharper could help you with this one :) ).

Frederik Gheysels
That is exactly the attribute I couldn't remember. It seems I couldn't remember what it really does as well :)
Sergej Andrejev