| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | using System.Collections.Generic; |
| | | 6 | | using System.Reflection; |
| | | 7 | | using CoreWCF.Collections.Generic; |
| | | 8 | | |
| | | 9 | | namespace CoreWCF.Dispatcher |
| | | 10 | | { |
| | | 11 | | public sealed class ClientOperation |
| | | 12 | | { |
| | | 13 | | private bool _serializeRequest; |
| | | 14 | | private bool _deserializeReply; |
| | | 15 | | private IClientFaultFormatter _faultFormatter; |
| | 507 | 16 | | private bool _isInitiating = true; |
| | | 17 | | private bool _isOneWay; |
| | | 18 | | private bool _isTerminating; |
| | | 19 | | private bool _isSessionOpenNotificationEnabled; |
| | | 20 | | private MethodInfo _beginMethod; |
| | | 21 | | private MethodInfo _endMethod; |
| | | 22 | | private MethodInfo _syncMethod; |
| | | 23 | | private MethodInfo _taskMethod; |
| | | 24 | | private Type _taskTResult; |
| | | 25 | | |
| | | 26 | | public ClientOperation(ClientRuntime parent, string name, string action) |
| | 0 | 27 | | : this(parent, name, action, null) |
| | | 28 | | { |
| | 0 | 29 | | } |
| | | 30 | | |
| | 507 | 31 | | public ClientOperation(ClientRuntime parent, string name, string action, string replyAction) |
| | | 32 | | { |
| | 507 | 33 | | Parent = parent ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(parent)); |
| | 507 | 34 | | Name = name ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(name)); |
| | 507 | 35 | | Action = action; |
| | 507 | 36 | | ReplyAction = replyAction; |
| | | 37 | | |
| | 507 | 38 | | FaultContractInfos = parent.NewBehaviorCollection<FaultContractInfo>(); |
| | 507 | 39 | | ParameterInspectors = parent.NewBehaviorCollection<IParameterInspector>(); |
| | 507 | 40 | | } |
| | | 41 | | |
| | 3 | 42 | | public string Action { get; } |
| | | 43 | | |
| | 2 | 44 | | internal SynchronizedCollection<FaultContractInfo> FaultContractInfos { get; } |
| | | 45 | | |
| | | 46 | | public MethodInfo BeginMethod |
| | | 47 | | { |
| | 2 | 48 | | get { return _beginMethod; } |
| | | 49 | | set |
| | | 50 | | { |
| | 2 | 51 | | lock (Parent.ThisLock) |
| | | 52 | | { |
| | 2 | 53 | | Parent.InvalidateRuntime(); |
| | 2 | 54 | | _beginMethod = value; |
| | 2 | 55 | | } |
| | 2 | 56 | | } |
| | | 57 | | } |
| | | 58 | | |
| | | 59 | | public MethodInfo EndMethod |
| | | 60 | | { |
| | 0 | 61 | | get { return _endMethod; } |
| | | 62 | | set |
| | | 63 | | { |
| | 2 | 64 | | lock (Parent.ThisLock) |
| | | 65 | | { |
| | 2 | 66 | | Parent.InvalidateRuntime(); |
| | 2 | 67 | | _endMethod = value; |
| | 2 | 68 | | } |
| | 2 | 69 | | } |
| | | 70 | | } |
| | | 71 | | |
| | | 72 | | public MethodInfo SyncMethod |
| | | 73 | | { |
| | 2 | 74 | | get { return _syncMethod; } |
| | | 75 | | set |
| | | 76 | | { |
| | 2 | 77 | | lock (Parent.ThisLock) |
| | | 78 | | { |
| | 2 | 79 | | Parent.InvalidateRuntime(); |
| | 2 | 80 | | _syncMethod = value; |
| | 2 | 81 | | } |
| | 2 | 82 | | } |
| | | 83 | | } |
| | | 84 | | |
| | | 85 | | public IClientMessageFormatter Formatter |
| | | 86 | | { |
| | 4 | 87 | | get { return InternalFormatter; } |
| | | 88 | | set |
| | | 89 | | { |
| | 2 | 90 | | lock (Parent.ThisLock) |
| | | 91 | | { |
| | 2 | 92 | | Parent.InvalidateRuntime(); |
| | 2 | 93 | | InternalFormatter = value; |
| | 2 | 94 | | } |
| | 2 | 95 | | } |
| | | 96 | | } |
| | | 97 | | |
| | | 98 | | internal IClientFaultFormatter FaultFormatter |
| | | 99 | | { |
| | | 100 | | get |
| | | 101 | | { |
| | 2 | 102 | | if (_faultFormatter == null) |
| | | 103 | | { |
| | 2 | 104 | | _faultFormatter = new DataContractSerializerFaultFormatter(FaultContractInfos); |
| | | 105 | | } |
| | 2 | 106 | | return _faultFormatter; |
| | | 107 | | } |
| | | 108 | | set |
| | | 109 | | { |
| | 0 | 110 | | lock (Parent.ThisLock) |
| | | 111 | | { |
| | 0 | 112 | | Parent.InvalidateRuntime(); |
| | 0 | 113 | | _faultFormatter = value; |
| | 0 | 114 | | IsFaultFormatterSetExplicit = true; |
| | 0 | 115 | | } |
| | 0 | 116 | | } |
| | | 117 | | } |
| | | 118 | | |
| | 0 | 119 | | internal bool IsFaultFormatterSetExplicit { get; private set; } = false; |
| | | 120 | | |
| | 511 | 121 | | internal IClientMessageFormatter InternalFormatter { get; set; } |
| | | 122 | | |
| | | 123 | | public bool IsInitiating |
| | | 124 | | { |
| | 2 | 125 | | get { return _isInitiating; } |
| | | 126 | | set |
| | | 127 | | { |
| | 2 | 128 | | lock (Parent.ThisLock) |
| | | 129 | | { |
| | 2 | 130 | | Parent.InvalidateRuntime(); |
| | 2 | 131 | | _isInitiating = value; |
| | 2 | 132 | | } |
| | 2 | 133 | | } |
| | | 134 | | } |
| | | 135 | | |
| | | 136 | | public bool IsOneWay |
| | | 137 | | { |
| | 2 | 138 | | get { return _isOneWay; } |
| | | 139 | | set |
| | | 140 | | { |
| | 2 | 141 | | lock (Parent.ThisLock) |
| | | 142 | | { |
| | 2 | 143 | | Parent.InvalidateRuntime(); |
| | 2 | 144 | | _isOneWay = value; |
| | 2 | 145 | | } |
| | 2 | 146 | | } |
| | | 147 | | } |
| | | 148 | | |
| | | 149 | | public bool IsTerminating |
| | | 150 | | { |
| | 2 | 151 | | get { return _isTerminating; } |
| | | 152 | | set |
| | | 153 | | { |
| | 2 | 154 | | lock (Parent.ThisLock) |
| | | 155 | | { |
| | 2 | 156 | | Parent.InvalidateRuntime(); |
| | 2 | 157 | | _isTerminating = value; |
| | 2 | 158 | | } |
| | 2 | 159 | | } |
| | | 160 | | } |
| | | 161 | | |
| | 8 | 162 | | public string Name { get; } |
| | | 163 | | |
| | | 164 | | public ICollection<IParameterInspector> ClientParameterInspectors |
| | | 165 | | { |
| | 0 | 166 | | get { return ParameterInspectors; } |
| | | 167 | | } |
| | | 168 | | |
| | 3 | 169 | | internal SynchronizedCollection<IParameterInspector> ParameterInspectors { get; } |
| | | 170 | | |
| | 50 | 171 | | public ClientRuntime Parent { get; } |
| | | 172 | | |
| | 2 | 173 | | public string ReplyAction { get; } |
| | | 174 | | |
| | | 175 | | public bool SerializeRequest |
| | | 176 | | { |
| | 2 | 177 | | get { return _serializeRequest; } |
| | | 178 | | set |
| | | 179 | | { |
| | 2 | 180 | | lock (Parent.ThisLock) |
| | | 181 | | { |
| | 2 | 182 | | Parent.InvalidateRuntime(); |
| | 2 | 183 | | _serializeRequest = value; |
| | 2 | 184 | | } |
| | 2 | 185 | | } |
| | | 186 | | } |
| | | 187 | | |
| | | 188 | | public bool DeserializeReply |
| | | 189 | | { |
| | 2 | 190 | | get { return _deserializeReply; } |
| | | 191 | | set |
| | | 192 | | { |
| | 2 | 193 | | lock (Parent.ThisLock) |
| | | 194 | | { |
| | 2 | 195 | | Parent.InvalidateRuntime(); |
| | 2 | 196 | | _deserializeReply = value; |
| | 2 | 197 | | } |
| | 2 | 198 | | } |
| | | 199 | | } |
| | | 200 | | |
| | | 201 | | public MethodInfo TaskMethod |
| | | 202 | | { |
| | 2 | 203 | | get { return _taskMethod; } |
| | | 204 | | set |
| | | 205 | | { |
| | 2 | 206 | | lock (Parent.ThisLock) |
| | | 207 | | { |
| | 2 | 208 | | Parent.InvalidateRuntime(); |
| | 2 | 209 | | _taskMethod = value; |
| | 2 | 210 | | } |
| | 2 | 211 | | } |
| | | 212 | | } |
| | | 213 | | |
| | | 214 | | public Type TaskTResult |
| | | 215 | | { |
| | 2 | 216 | | get { return _taskTResult; } |
| | | 217 | | set |
| | | 218 | | { |
| | 2 | 219 | | lock (Parent.ThisLock) |
| | | 220 | | { |
| | 2 | 221 | | Parent.InvalidateRuntime(); |
| | 2 | 222 | | _taskTResult = value; |
| | 2 | 223 | | } |
| | 2 | 224 | | } |
| | | 225 | | } |
| | | 226 | | |
| | | 227 | | internal bool IsSessionOpenNotificationEnabled |
| | | 228 | | { |
| | 2 | 229 | | get { return _isSessionOpenNotificationEnabled; } |
| | | 230 | | set |
| | | 231 | | { |
| | 2 | 232 | | lock (Parent.ThisLock) |
| | | 233 | | { |
| | 2 | 234 | | Parent.InvalidateRuntime(); |
| | 2 | 235 | | _isSessionOpenNotificationEnabled = value; |
| | 2 | 236 | | } |
| | 2 | 237 | | } |
| | | 238 | | } |
| | | 239 | | } |
| | | 240 | | } |