I'm looking at the System.ServiceModel.OperationContext
http://msdn.microsoft.com/en-us/library/system.servicemodel.operationcontext(v=vs.110).aspx
I'm trying to understand the difference between:
OperationContext.Current
OperationContext.InstanceContext
OperationContext.RequestContext
In my testing, they seem to be the same. What am I missing?
Well the obvious answer is that they are not exactly the same. At a high level they are three different Types, not inheriting from a common interface. more specifically they have different properties from each other. But from the way you're asking your question it seems you'd also be interested in what each is used for.
In looking at the msdn documentation, I've pulled out some points from the remarks with some of my own thoughts, as to why it has each of the contexts.
Current(OperationContext) : "the operation context is used to access callback channels in duplex services, to store extra state data across portions of the operations, and to access incoming message headers and properties as well as add outgoing message headers and properties."
RequestContext : "the RequestContext object is the link between the request that comes in and the reply that goes out" this object is really focused on giving you access and control over requests and replies in your service.
InstanceContext : no msdn remarks here, but looking at it, it gives you more in-depth control over the state of the communication infrastructure. i.e the communication channels, hosts, and extensions.
Here are the specific MSDN articles I was looking at for each
OperationContext : http://msdn.microsoft.com/en-us/library/system.servicemodel.operationcontext(v=vs.110).aspx
RequestContext : http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.requestcontext(v=vs.110).aspx
InstanceContext : http://msdn.microsoft.com/en-us/library/system.servicemodel.instancecontext(v=vs.110).aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With