DispatchOperation.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //-----------------------------------------------------------------------------
  4. namespace System.ServiceModel.Dispatcher
  5. {
  6. using System.ServiceModel;
  7. using System.Collections.Generic;
  8. public sealed class DispatchOperation
  9. {
  10. string action;
  11. SynchronizedCollection<ICallContextInitializer> callContextInitializers;
  12. SynchronizedCollection<FaultContractInfo> faultContractInfos;
  13. IDispatchMessageFormatter formatter;
  14. IDispatchFaultFormatter faultFormatter;
  15. bool includeExceptionDetailInFaults;
  16. ImpersonationOption impersonation;
  17. IOperationInvoker invoker;
  18. bool isTerminating;
  19. bool isSessionOpenNotificationEnabled;
  20. string name;
  21. SynchronizedCollection<IParameterInspector> parameterInspectors;
  22. DispatchRuntime parent;
  23. bool releaseInstanceAfterCall;
  24. bool releaseInstanceBeforeCall;
  25. string replyAction;
  26. bool transactionAutoComplete;
  27. bool transactionRequired;
  28. bool deserializeRequest = true;
  29. bool serializeReply = true;
  30. bool isOneWay;
  31. bool autoDisposeParameters = true;
  32. bool hasNoDisposableParameters;
  33. bool isFaultFormatterSetExplicit = false;
  34. bool isInsideTransactedReceiveScope = false;
  35. public DispatchOperation(DispatchRuntime parent, string name, string action)
  36. {
  37. if (parent == null)
  38. throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parent");
  39. if (name == null)
  40. throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("name");
  41. this.parent = parent;
  42. this.name = name;
  43. this.action = action;
  44. this.impersonation = OperationBehaviorAttribute.DefaultImpersonationOption;
  45. this.callContextInitializers = parent.NewBehaviorCollection<ICallContextInitializer>();
  46. this.faultContractInfos = parent.NewBehaviorCollection<FaultContractInfo>();
  47. this.parameterInspectors = parent.NewBehaviorCollection<IParameterInspector>();
  48. this.isOneWay = true;
  49. }
  50. public DispatchOperation(DispatchRuntime parent, string name, string action, string replyAction)
  51. : this(parent, name, action)
  52. {
  53. this.replyAction = replyAction;
  54. this.isOneWay = false;
  55. }
  56. public bool IsOneWay
  57. {
  58. get { return this.isOneWay; }
  59. }
  60. public string Action
  61. {
  62. get { return this.action; }
  63. }
  64. public SynchronizedCollection<ICallContextInitializer> CallContextInitializers
  65. {
  66. get { return this.callContextInitializers; }
  67. }
  68. public SynchronizedCollection<FaultContractInfo> FaultContractInfos
  69. {
  70. get { return this.faultContractInfos; }
  71. }
  72. public bool AutoDisposeParameters
  73. {
  74. get { return this.autoDisposeParameters; }
  75. set
  76. {
  77. lock (this.parent.ThisLock)
  78. {
  79. this.parent.InvalidateRuntime();
  80. this.autoDisposeParameters = value;
  81. }
  82. }
  83. }
  84. public IDispatchMessageFormatter Formatter
  85. {
  86. get { return this.formatter; }
  87. set
  88. {
  89. lock (this.parent.ThisLock)
  90. {
  91. this.parent.InvalidateRuntime();
  92. this.formatter = value;
  93. }
  94. }
  95. }
  96. internal IDispatchFaultFormatter FaultFormatter
  97. {
  98. get
  99. {
  100. if (this.faultFormatter == null)
  101. {
  102. this.faultFormatter = new DataContractSerializerFaultFormatter(this.faultContractInfos);
  103. }
  104. return this.faultFormatter;
  105. }
  106. set
  107. {
  108. lock (this.parent.ThisLock)
  109. {
  110. this.parent.InvalidateRuntime();
  111. this.faultFormatter = value;
  112. this.isFaultFormatterSetExplicit = true;
  113. }
  114. }
  115. }
  116. internal bool IncludeExceptionDetailInFaults
  117. {
  118. get
  119. {
  120. return this.includeExceptionDetailInFaults;
  121. }
  122. set
  123. {
  124. this.includeExceptionDetailInFaults = value;
  125. }
  126. }
  127. internal bool IsFaultFormatterSetExplicit
  128. {
  129. get
  130. {
  131. return this.isFaultFormatterSetExplicit;
  132. }
  133. }
  134. public ImpersonationOption Impersonation
  135. {
  136. get { return this.impersonation; }
  137. set
  138. {
  139. lock (this.parent.ThisLock)
  140. {
  141. this.parent.InvalidateRuntime();
  142. this.impersonation = value;
  143. }
  144. }
  145. }
  146. internal bool HasNoDisposableParameters
  147. {
  148. get { return this.hasNoDisposableParameters; }
  149. set { this.hasNoDisposableParameters = value; }
  150. }
  151. internal IDispatchMessageFormatter InternalFormatter
  152. {
  153. get { return this.formatter; }
  154. set { this.formatter = value; }
  155. }
  156. internal IOperationInvoker InternalInvoker
  157. {
  158. get { return this.invoker; }
  159. set { this.invoker = value; }
  160. }
  161. public IOperationInvoker Invoker
  162. {
  163. get { return this.invoker; }
  164. set
  165. {
  166. lock (this.parent.ThisLock)
  167. {
  168. this.parent.InvalidateRuntime();
  169. this.invoker = value;
  170. }
  171. }
  172. }
  173. public bool IsTerminating
  174. {
  175. get { return this.isTerminating; }
  176. set
  177. {
  178. lock (this.parent.ThisLock)
  179. {
  180. this.parent.InvalidateRuntime();
  181. this.isTerminating = value;
  182. }
  183. }
  184. }
  185. internal bool IsSessionOpenNotificationEnabled
  186. {
  187. get { return this.isSessionOpenNotificationEnabled; }
  188. set
  189. {
  190. lock (this.parent.ThisLock)
  191. {
  192. this.parent.InvalidateRuntime();
  193. this.isSessionOpenNotificationEnabled = value;
  194. }
  195. }
  196. }
  197. public string Name
  198. {
  199. get { return this.name; }
  200. }
  201. public SynchronizedCollection<IParameterInspector> ParameterInspectors
  202. {
  203. get { return this.parameterInspectors; }
  204. }
  205. public DispatchRuntime Parent
  206. {
  207. get { return this.parent; }
  208. }
  209. internal ReceiveContextAcknowledgementMode ReceiveContextAcknowledgementMode
  210. {
  211. get;
  212. set;
  213. }
  214. internal bool BufferedReceiveEnabled
  215. {
  216. get { return this.parent.ChannelDispatcher.BufferedReceiveEnabled; }
  217. set { this.parent.ChannelDispatcher.BufferedReceiveEnabled = value; }
  218. }
  219. public bool ReleaseInstanceAfterCall
  220. {
  221. get { return this.releaseInstanceAfterCall; }
  222. set
  223. {
  224. lock (this.parent.ThisLock)
  225. {
  226. this.parent.InvalidateRuntime();
  227. this.releaseInstanceAfterCall = value;
  228. }
  229. }
  230. }
  231. public bool ReleaseInstanceBeforeCall
  232. {
  233. get { return this.releaseInstanceBeforeCall; }
  234. set
  235. {
  236. lock (this.parent.ThisLock)
  237. {
  238. this.parent.InvalidateRuntime();
  239. this.releaseInstanceBeforeCall = value;
  240. }
  241. }
  242. }
  243. public string ReplyAction
  244. {
  245. get { return this.replyAction; }
  246. }
  247. public bool DeserializeRequest
  248. {
  249. get { return this.deserializeRequest; }
  250. set
  251. {
  252. lock (this.parent.ThisLock)
  253. {
  254. this.parent.InvalidateRuntime();
  255. this.deserializeRequest = value;
  256. }
  257. }
  258. }
  259. public bool SerializeReply
  260. {
  261. get { return this.serializeReply; }
  262. set
  263. {
  264. lock (this.parent.ThisLock)
  265. {
  266. this.parent.InvalidateRuntime();
  267. this.serializeReply = value;
  268. }
  269. }
  270. }
  271. public bool TransactionAutoComplete
  272. {
  273. get { return this.transactionAutoComplete; }
  274. set
  275. {
  276. lock (this.parent.ThisLock)
  277. {
  278. this.parent.InvalidateRuntime();
  279. this.transactionAutoComplete = value;
  280. }
  281. }
  282. }
  283. public bool TransactionRequired
  284. {
  285. get { return this.transactionRequired; }
  286. set
  287. {
  288. lock (this.parent.ThisLock)
  289. {
  290. this.parent.InvalidateRuntime();
  291. this.transactionRequired = value;
  292. }
  293. }
  294. }
  295. public bool IsInsideTransactedReceiveScope
  296. {
  297. get { return this.isInsideTransactedReceiveScope; }
  298. set
  299. {
  300. lock (this.parent.ThisLock)
  301. {
  302. this.parent.InvalidateRuntime();
  303. this.isInsideTransactedReceiveScope = value;
  304. }
  305. }
  306. }
  307. }
  308. }