2009-09-04 Zoltan Varga <vargaz@gmail.com>
[mcs.git] / class / System.ServiceModel / System.ServiceModel.Dispatcher / InitializingHandler.cs
blobe2d23f0464c2fbfcaea365b777c4f6b40e571689
1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4 using System.ServiceModel.Channels;
5 using System.ServiceModel;
7 namespace System.ServiceModel.Dispatcher
9 internal class InitializingHandler : BaseRequestProcessorHandler
11 protected override bool ProcessRequest (MessageProcessingContext mrc)
13 InstanceContext ictx = CreateInstanceContext (mrc);
14 mrc.InstanceContext = ictx;
15 mrc.OperationContext.InstanceContext = ictx;
16 return false;
19 InstanceContext CreateInstanceContext (MessageProcessingContext mrc)
21 InstanceContext iCtx = null;
22 DispatchRuntime dispatchRuntime = mrc.OperationContext.EndpointDispatcher.DispatchRuntime;
23 IInstanceContextProvider p = dispatchRuntime.InstanceContextProvider;
25 if (p != null) {
26 iCtx = p.GetExistingInstanceContext (mrc.IncomingMessage, mrc.OperationContext.Channel);
28 if (iCtx == null) {
29 ServiceHostBase host = dispatchRuntime.ChannelDispatcher.Host;
30 iCtx = new InstanceContext (dispatchRuntime.ChannelDispatcher.Host, null, false);
33 iCtx.Behavior = new InstanceBehavior (dispatchRuntime);
34 return iCtx;