I’ve seen examples of this where an interface is provided to a factory and it generates objects that implement the interface. This isn’t that complicated to me, but what I don’t get is how that can be used to implement behavior.
Take for example the ChannelFactory in WCF… when you generate a channel from an interface it exposes methods (from the interface) that when invoked call remote procedures. I seem to have a small gap in my knowledge on how this can be done. It’s probably a common design pattern but I figured I’d use SO as a research extension once again.
Usually happens through code emission. See the classes in System.Reflection.Emit.
For example, you could get an interface Type and go over the methods it declares, then build your own type which inherits it, using TypeBuilder, and implement whatever functionality you desire in the methods (or just them make empty / do a return default(T)), using MethodBuilder, and so on, until you’ve satisfied the interface.