2 // DispatchOperation.cs
5 // Atsushi Enomoto <atsushi@ximian.com>
7 // Copyright (C) 2005-2010 Novell, Inc. http://www.novell.com
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:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
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.
29 using System.Collections.Generic;
30 using System.Reflection;
31 using System.ServiceModel;
32 using System.ServiceModel.Channels;
33 using System.ServiceModel.Description;
36 namespace System.ServiceModel.Dispatcher
38 public sealed class DispatchOperation
40 internal class DispatchOperationCollection :
41 SynchronizedKeyedCollection<string, DispatchOperation>
43 protected override string GetKeyForItem (DispatchOperation o)
49 DispatchRuntime parent;
50 string name, action, reply_action;
51 bool serialize_reply = true, deserialize_request = true,
52 is_oneway, is_terminating,
53 release_after_call, release_before_call,
54 tx_auto_complete, tx_required,
55 auto_dispose_params = true;
56 IDispatchMessageFormatter formatter;
58 ImpersonationOption impersonation;
59 IOperationInvoker invoker;
60 SynchronizedCollection<IParameterInspector> inspectors
61 = new SynchronizedCollection<IParameterInspector> ();
62 SynchronizedCollection<FaultContractInfo> fault_contract_infos
63 = new SynchronizedCollection<FaultContractInfo> ();
64 SynchronizedCollection<ICallContextInitializer> ctx_initializers
65 = new SynchronizedCollection<ICallContextInitializer> ();
68 public DispatchOperation (DispatchRuntime parent,
69 string name, string action)
72 throw new ArgumentNullException ("parent");
74 throw new ArgumentNullException ("name");
75 // action could be null
83 public DispatchOperation (DispatchRuntime parent,
84 string name, string action, string replyAction)
85 : this (parent, name, action)
87 // replyAction could be null
89 reply_action = replyAction;
92 public string Action {
93 get { return action; }
97 public SynchronizedCollection<ICallContextInitializer> CallContextInitializers {
98 get { return ctx_initializers; }
101 public SynchronizedCollection<FaultContractInfo> FaultContractInfos {
102 get { return fault_contract_infos; }
105 [MonoTODO ("not considered")]
106 public ImpersonationOption Impersonation {
107 get { return impersonation; }
110 impersonation = value;
114 public IOperationInvoker Invoker {
115 get { return invoker; }
122 public bool IsTerminating {
123 get { return is_terminating; }
126 is_terminating = value;
130 public SynchronizedCollection<IParameterInspector> ParameterInspectors {
131 get { return inspectors; }
134 public bool ReleaseInstanceAfterCall {
135 get { return release_after_call; }
138 release_after_call = value;
142 public bool ReleaseInstanceBeforeCall {
143 get { return release_before_call; }
146 release_before_call = value;
150 public string ReplyAction {
151 get { return reply_action; }
154 public bool TransactionAutoComplete {
155 get { return tx_auto_complete; }
158 tx_auto_complete = value;
162 public bool TransactionRequired {
163 get { return tx_required; }
171 public bool AutoDisposeParameters {
172 get { return auto_dispose_params; }
175 auto_dispose_params = value;
179 public bool DeserializeRequest {
180 get { return deserialize_request; }
183 deserialize_request = value;
187 public IDispatchMessageFormatter Formatter {
188 get { return formatter; }
195 public bool IsOneWay {
196 get { return is_oneway; }
203 public DispatchRuntime Parent {
204 get { return parent; }
207 public bool SerializeReply {
208 get { return serialize_reply; }
211 serialize_reply = value;
215 void ThrowIfOpened ()
217 #if !NET_2_1 && !XAMMAC_4_5
218 // FIXME: get callback client runtime status when ChannelDispatcher is not available.
219 var state = Parent.ChannelDispatcher != null ? Parent.ChannelDispatcher.State : CommunicationState.Created; // Parent.CallbackClientRuntime.ChannelFactory.State;
221 case CommunicationState.Created:
222 case CommunicationState.Opening:
225 throw new InvalidOperationException ("Cannot change this property after the service host is opened");