Freigeben über


Just Exactly What You Asked For

When implementing a transport or layered channel class the marker used to indicate that your class is a channel is to implement the IChannel interface. Therefore, all channels will implement one of the known channel shapes: IInputChannel, IOutputChannel, IDuplexChannel, IRequestChannel, or IReplyChannel (optionally you might use the sessionful variant of one of these channel shapes instead).

If your channel logically happens to support more than one of these channel shapes, then you should factor the implementation into multiple classes, each class supporting exactly one of the channel shapes. That is, each channel class should implement exactly one of the channel shapes. You can use inheritance or other means to share the implementation between the different channel classes as long as you adhere to the restriction on implementing shapes.

The reason for the restriction is that a number of consumers interact with a channel based on its type rather than the type provided when creating the channel. This allows the consumer to avoid carrying this state information around. However, it means that if you implement channel interfaces that are not the actual type of the channel, then those consumers will act on your channel incorrectly based on the type that they see.