开发者

Using one class instead of another

I remember .Net had a feature (don't remember whether it was a configuration option or assemby attribute) which would replace one class with an开发者_如何学编程other.

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


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 :) ).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜