Looking over Peter’s slides from his SSCLI remoting talk in Cambridge reminded me of a little experiment I did last fall.
It’s a class I wrote called MyGenericProxy. A MyGenericProxy acts like any type you tell it to act like (as long as the object is stateless). It does this by constructing an real object of that type behind the scenes (using reflection) and calling methods on that object based on the messages it receives. After you construct it, you call GetTransparentProxy on it and cast the object returned to the type you want it to act like. Then you can treat this object just like an object of the type you specified.
I discovered that if two types have the same inheritance hierarchy, you can even switch between them on the fly. This little program demonstrates this.
I can’t say it’s useful, but it did teach me a thing or two about proxies.
4:56:43 PM
|