2 using System
.Collections
.Generic
;
4 using System
.ServiceModel
;
5 using System
.ServiceModel
.Channels
;
7 namespace Microsoft
.ServiceModel
.Samples
9 class DurableInstanceContextRequestSessionChannel
: DurableInstanceContextChannelBase
,
10 IRequestSessionChannel
12 IRequestSessionChannel innerRequestSessionChannel
;
14 // Indicates whether the current message is the first
15 // message in a session or not.
18 // Lock should be acquired on this object before changing the
19 // state of this channel.
22 public DurableInstanceContextRequestSessionChannel(ChannelManagerBase channelManager
,
23 ContextType contextType
,
24 IRequestSessionChannel innerChannel
,
25 string contextStoreLocation
)
26 : base(channelManager
, innerChannel
)
28 this.contextType
= contextType
;
29 this.innerRequestSessionChannel
= innerChannel
;
30 this.contextStoreLocation
= contextStoreLocation
;
31 this.endpointAddress
= innerChannel
.RemoteAddress
;
32 this.stateLock
= new object();
33 this.isFirstMessage
= true;
36 public IOutputSession Session
40 return innerRequestSessionChannel
.Session
;
44 public IAsyncResult
BeginRequest(Message message
, TimeSpan timeout
,
45 AsyncCallback callback
, object state
)
49 // Apply the context if the message is the first message.
52 ApplyContext(message
);
53 isFirstMessage
= false;
57 return innerRequestSessionChannel
.BeginRequest(message
, timeout
,
61 public IAsyncResult
BeginRequest(Message message
,
62 AsyncCallback callback
, object state
)
64 return BeginRequest(message
, DefaultSendTimeout
, callback
, state
);
67 public Message
EndRequest(IAsyncResult result
)
69 return innerRequestSessionChannel
.EndRequest(result
);
72 public EndpointAddress RemoteAddress
76 return innerRequestSessionChannel
.RemoteAddress
;
80 public Message
Request(Message message
, TimeSpan timeout
)
84 // Apply the context if the message is the first message.
87 ApplyContext(message
);
88 isFirstMessage
= false;
92 return innerRequestSessionChannel
.Request(message
, timeout
);
95 public Message
Request(Message message
)
97 return Request(message
, DefaultSendTimeout
);
104 return innerRequestSessionChannel
.Via
;