2009-08-17 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mcs / class / System.ServiceModel / System.ServiceModel.Dispatcher / EndpointDispatcher.cs
1 //
2 // EndpointDispatcher.cs
3 //
4 // Author:
5 //      Atsushi Enomoto <atsushi@ximian.com>
6 //
7 // Copyright (C) 2005-2006 Novell, Inc.  http://www.novell.com
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 // 
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 // 
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28 using System;
29 using System.Collections.Generic;
30 using System.Collections.ObjectModel;
31 using System.Reflection;
32 using System.ServiceModel.Description;
33 using System.ServiceModel.Channels;
34 using System.ServiceModel.Dispatcher;
35 using System.ServiceModel.Security.Tokens;
36 using System.Text;
37
38 namespace System.ServiceModel.Dispatcher
39 {
40         public class EndpointDispatcher
41         {
42                 EndpointAddress address;
43                 string contract_name, contract_ns;
44                 ChannelDispatcher channel_dispatcher;
45                 MessageFilter address_filter;
46                 MessageFilter contract_filter;
47                 int filter_priority;
48                 DispatchRuntime dispatch_runtime;
49
50                 // Umm, this API is ugly, since it or its members will
51                 // anyways require ServiceEndpoint, those arguments are
52                 // likely to be replaced by ServiceEndpoint (especially
53                 // considering about possible EndpointAddress inconsistency).
54                 public EndpointDispatcher (EndpointAddress address,
55                         string contractName, string contractNamespace)
56                 {
57                         if (contractName == null)
58                                 throw new ArgumentNullException ("contractName");
59                         if (contractNamespace == null)
60                                 throw new ArgumentNullException ("contractNamespace");
61                         if (address == null)
62                                 throw new ArgumentNullException ("address");
63
64                         this.address = address;
65                         contract_name = contractName;
66                         contract_ns = contractNamespace;
67
68                         dispatch_runtime = new DispatchRuntime (this);
69                 }
70
71                 public DispatchRuntime DispatchRuntime {
72                         get { return dispatch_runtime; }
73                 }
74
75                 public string ContractName {
76                         get { return contract_name; }
77                 }
78
79                 public string ContractNamespace {
80                         get { return contract_ns; }
81                 }
82
83                 public ChannelDispatcher ChannelDispatcher {
84                         get { return channel_dispatcher; }
85                         internal set { channel_dispatcher = value; }
86                 }
87
88                 public MessageFilter AddressFilter {
89                         get { return address_filter; }
90                         set {
91                                 if (value == null)
92                                         throw new ArgumentNullException ("value");
93                                 address_filter = value;
94                         }
95                 }
96
97                 public MessageFilter ContractFilter {
98                         get { return contract_filter ?? (contract_filter = new MatchAllMessageFilter ()); }
99                         set {
100                                 if (value == null)
101                                         throw new ArgumentNullException ("value");
102                                 contract_filter = value;
103                         }
104                 }
105
106                 public EndpointAddress EndpointAddress {
107                         get { return address; }
108                 }
109
110                 public int FilterPriority {
111                         get { return filter_priority; }
112                         set { filter_priority = value; }
113                 }
114         }
115 }