2010-04-06 Jb Evain <jbevain@novell.com>
[mcs.git] / class / System.ServiceModel / System.ServiceModel.Dispatcher / InputOrReplyRequestProcessor.cs
blob359d5381b8b56c5b24260d1978224a5ff3e828df
1 using System;
2 using System.Collections.Generic;
3 using System.ServiceModel;
4 using System.ServiceModel.Channels;
5 using System.ServiceModel.Security;
6 using System.ServiceModel.Security.Tokens;
7 using System.Text;
8 using System.ServiceModel.MonoInternal;
10 namespace System.ServiceModel.Dispatcher
12 internal class InputOrReplyRequestProcessor : BaseRequestProcessor
14 DispatchRuntime dispatch_runtime;
15 IChannel reply_or_input;
17 public InputOrReplyRequestProcessor (DispatchRuntime runtime, IChannel replyOrInput)
19 Init (runtime, replyOrInput);
21 //initialization
22 InitializeChain.AddHandler (new InitializingHandler ());
24 //processing
25 ProcessingChain.AddHandler (new PostReceiveRequestHandler ()).
26 AddHandler(new SecurityHandler ()).
27 AddHandler(new OperationInvokerHandler (replyOrInput));
29 //errors
30 ErrorChain.AddHandler (new ErrorProcessingHandler (replyOrInput));
32 //finalize
33 FinalizationChain.AddHandler (new FinalizeProcessingHandler ());
36 void Init (DispatchRuntime runtime, IChannel replyOrInput)
38 dispatch_runtime = runtime;
39 reply_or_input = replyOrInput;
42 public void ProcessInput (Message message)
44 OperationContext opcx = CreateOperationContext (message);
45 ProcessRequest (new MessageProcessingContext (opcx));
48 public void ProcessReply (RequestContext rc)
50 OperationContext opcx = CreateOperationContext (rc.RequestMessage);
51 opcx.RequestContext = rc;
52 ProcessRequest (new MessageProcessingContext (opcx));
55 OperationContext CreateOperationContext (Message incoming)
57 ServiceRuntimeChannel contextChannel;
58 if (dispatch_runtime.HasCallbackRuntime) {
59 var type = ServiceProxyGenerator.CreateCallbackProxyType (dispatch_runtime.Type, dispatch_runtime.CallbackClientRuntime.CallbackClientType);
60 contextChannel = (ServiceRuntimeChannel) Activator.CreateInstance (type, new object [] {reply_or_input, dispatch_runtime});
62 else
63 contextChannel = new ServiceRuntimeChannel (reply_or_input, dispatch_runtime);
64 OperationContext opCtx = new OperationContext (contextChannel);
65 opCtx.IncomingMessage = incoming;
66 opCtx.EndpointDispatcher = dispatch_runtime.EndpointDispatcher;
67 return opCtx;