2009-06-12 Bill Holmes <billholmes54@gmail.com>
[mono.git] / mcs / class / System.ServiceModel / System.ServiceModel.Dispatcher / InputOrReplyRequestProcessor.cs
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
9 namespace System.ServiceModel.Dispatcher
10 {
11         internal class InputOrReplyRequestProcessor : BaseRequestProcessor
12         {
13                 DispatchRuntime dispatch_runtime;
14                 IChannel reply_or_input;
15
16                 public InputOrReplyRequestProcessor (DispatchRuntime runtime, IChannel replyOrInput)
17                 {
18                         Init (runtime, reply_or_input);
19
20                         //initialization
21                         InitializeChain.AddHandler (new InitializingHandler ());
22
23                         //processing
24                         ProcessingChain.AddHandler (new PostReceiveRequestHandler ()).
25                                                         AddHandler(new SecurityHandler ()).
26                                                         AddHandler(new OperationInvokerHandler ()).
27                                                         AddHandler(new ReplyHandler (replyOrInput));
28
29                         //errors
30                         ErrorChain.AddHandler (new ErrorProcessingHandler (replyOrInput));
31
32                         //finalize
33                         FinalizationChain.AddHandler (new FinalizeProcessingHandler ());
34                 }
35
36                 void Init (DispatchRuntime runtime, IChannel replyOrInput)
37                 {
38                         dispatch_runtime = runtime;
39                         reply_or_input = replyOrInput;
40                 }
41
42                 public void ProcessInput (Message message)
43                 {
44                         OperationContext opcx = CreateOperationContext (message);
45                         ProcessRequest (new MessageProcessingContext (opcx));
46                 }
47
48                 public void ProcessReply (RequestContext rc)
49                 {
50                         OperationContext opcx = CreateOperationContext (rc.RequestMessage);
51                         opcx.RequestContext = rc;
52                         ProcessRequest (new MessageProcessingContext (opcx));
53                 }
54
55                 OperationContext CreateOperationContext (Message incoming)
56                 {
57                         ServiceRuntimeChannel contextChannel = new ServiceRuntimeChannel (reply_or_input,
58                                                                                                         dispatch_runtime.ChannelDispatcher.DefaultOpenTimeout,
59                                                                                                         dispatch_runtime.ChannelDispatcher.DefaultCloseTimeout);
60                         OperationContext opCtx = new OperationContext (contextChannel);
61                         opCtx.IncomingMessage = incoming;
62                         opCtx.EndpointDispatcher = dispatch_runtime.EndpointDispatcher;
63                         return opCtx;
64                 }
65         }
66 }