internal ImmutableClientRuntime(ClientRuntime behavior) { _channelInitializers = EmptyArray <IChannelInitializer> .ToArray(behavior.ChannelInitializers); _interactiveChannelInitializers = EmptyArray <IInteractiveChannelInitializer> .ToArray(behavior.InteractiveChannelInitializers); _messageInspectors = EmptyArray <IClientMessageInspector> .ToArray(behavior.MessageInspectors); _operationSelector = behavior.OperationSelector; _useSynchronizationContext = behavior.UseSynchronizationContext; _validateMustUnderstand = behavior.ValidateMustUnderstand; _unhandled = new ProxyOperationRuntime(behavior.UnhandledClientOperation, this); _addTransactionFlowProperties = behavior.AddTransactionFlowProperties; _operations = new Dictionary <string, ProxyOperationRuntime>(); for (int i = 0; i < behavior.Operations.Count; i++) { ClientOperation operation = behavior.Operations[i]; ProxyOperationRuntime operationRuntime = new ProxyOperationRuntime(operation, this); _operations.Add(operation.Name, operationRuntime); } _correlationCount = _messageInspectors.Length + behavior.MaxParameterInspectors; }
//readonly bool isInsideTransactedReceiveScope; internal DispatchOperationRuntime(DispatchOperation operation, ImmutableDispatchRuntime parent) { if (operation == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(operation)); } if (operation.Invoker == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.RuntimeRequiresInvoker0)); } DisposeParameters = ((operation.AutoDisposeParameters) && (!operation.HasNoDisposableParameters)); Parent = parent ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(parent)); CallContextInitializers = EmptyArray <ICallContextInitializer> .ToArray(operation.CallContextInitializers); ParameterInspectors = EmptyArray <IParameterInspector> .ToArray(operation.ParameterInspectors); FaultFormatter = operation.FaultFormatter; Impersonation = operation.Impersonation; AuthorizeClaims = operation.AuthorizeClaims; _deserializeRequest = operation.DeserializeRequest; SerializeReply = operation.SerializeReply; Formatter = operation.Formatter; Invoker = operation.Invoker; IsTerminating = operation.IsTerminating; _isSessionOpenNotificationEnabled = operation.IsSessionOpenNotificationEnabled; Action = operation.Action; Name = operation.Name; ReleaseInstanceAfterCall = operation.ReleaseInstanceAfterCall; ReleaseInstanceBeforeCall = operation.ReleaseInstanceBeforeCall; ReplyAction = operation.ReplyAction; IsOneWay = operation.IsOneWay; ReceiveContextAcknowledgementMode = operation.ReceiveContextAcknowledgementMode; if (Formatter == null && (_deserializeRequest || SerializeReply)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.DispatchRuntimeRequiresFormatter0, Name))); } if ((operation.Parent.InstanceProvider == null) && (operation.Parent.Type != null)) { if (Invoker is SyncMethodInvoker sync) { ValidateInstanceType(operation.Parent.Type, sync.Method); } //AsyncMethodInvoker async = this.invoker as AsyncMethodInvoker; //if (async != null) //{ // this.ValidateInstanceType(operation.Parent.Type, async.BeginMethod); // this.ValidateInstanceType(operation.Parent.Type, async.EndMethod); //} if (Invoker is TaskMethodInvoker task) { ValidateInstanceType(operation.Parent.Type, task.TaskMethod); } } }
internal DispatchOperationRuntime(DispatchOperation operation, ImmutableDispatchRuntime parent) { if (operation == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(operation)); } if (operation.Invoker == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.RuntimeRequiresInvoker0)); } _disposeParameters = ((operation.AutoDisposeParameters) && (!operation.HasNoDisposableParameters)); Parent = parent ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(parent)); ParameterInspectors = EmptyArray <IParameterInspector> .ToArray(operation.ParameterInspectors); FaultFormatter = operation.FaultFormatter; _deserializeRequest = operation.DeserializeRequest; _serializeReply = operation.SerializeReply; Formatter = operation.Formatter; Invoker = operation.Invoker; IsTerminating = operation.IsTerminating; _isSessionOpenNotificationEnabled = operation.IsSessionOpenNotificationEnabled; Action = operation.Action; Name = operation.Name; ReplyAction = operation.ReplyAction; IsOneWay = operation.IsOneWay; if (Formatter == null && (_deserializeRequest || _serializeReply)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.DispatchRuntimeRequiresFormatter0, Name))); } }
internal ErrorBehavior(ChannelDispatcher channelDispatcher) { _handlers = EmptyArray <IErrorHandler> .ToArray(channelDispatcher.ErrorHandlers); _debug = channelDispatcher.IncludeExceptionDetailInFaults; _isOnServer = channelDispatcher.IsOnServer; _messageVersion = channelDispatcher.MessageVersion; }
internal ProxyOperationRuntime(ClientOperation operation, ImmutableClientRuntime parent) { if (operation == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("operation"); } if (parent == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parent"); } _parent = parent; _formatter = operation.Formatter; _isInitiating = operation.IsInitiating; _isOneWay = operation.IsOneWay; _isTerminating = operation.IsTerminating; _isSessionOpenNotificationEnabled = operation.IsSessionOpenNotificationEnabled; _name = operation.Name; _parameterInspectors = EmptyArray <IParameterInspector> .ToArray(operation.ParameterInspectors); _faultFormatter = operation.FaultFormatter; _serializeRequest = operation.SerializeRequest; _deserializeReply = operation.DeserializeReply; _action = operation.Action; _replyAction = operation.ReplyAction; _beginMethod = operation.BeginMethod; _syncMethod = operation.SyncMethod; _taskMethod = operation.TaskMethod; this.TaskTResult = operation.TaskTResult; if (_beginMethod != null) { _inParams = ServiceReflector.GetInputParameters(_beginMethod, true); if (_syncMethod != null) { _outParams = ServiceReflector.GetOutputParameters(_syncMethod, false); } else { _outParams = Array.Empty <ParameterInfo>(); } _endOutParams = ServiceReflector.GetOutputParameters(operation.EndMethod, true); _returnParam = operation.EndMethod.ReturnParameter; } else if (_syncMethod != null) { _inParams = ServiceReflector.GetInputParameters(_syncMethod, false); _outParams = ServiceReflector.GetOutputParameters(_syncMethod, false); _returnParam = _syncMethod.ReturnParameter; } if (_formatter == null && (_serializeRequest || _deserializeReply)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.ClientRuntimeRequiresFormatter0, _name))); } }
internal ProxyOperationRuntime(ClientOperation operation, ImmutableClientRuntime parent) { if (operation == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("operation"); } if (parent == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parent"); } this.parent = parent; this.formatter = operation.Formatter; this.isInitiating = operation.IsInitiating; this.isOneWay = operation.IsOneWay; this.isTerminating = operation.IsTerminating; this.isSessionOpenNotificationEnabled = operation.IsSessionOpenNotificationEnabled; this.name = operation.Name; this.parameterInspectors = EmptyArray <IParameterInspector> .ToArray(operation.ParameterInspectors); this.faultFormatter = operation.FaultFormatter; this.serializeRequest = operation.SerializeRequest; this.deserializeReply = operation.DeserializeReply; this.action = operation.Action; this.replyAction = operation.ReplyAction; this.beginMethod = operation.BeginMethod; this.syncMethod = operation.SyncMethod; this.taskMethod = operation.TaskMethod; this.TaskTResult = operation.TaskTResult; if (this.beginMethod != null) { this.inParams = ServiceReflector.GetInputParameters(this.beginMethod, true); if (this.syncMethod != null) { this.outParams = ServiceReflector.GetOutputParameters(this.syncMethod, false); } else { this.outParams = NoParams; } this.endOutParams = ServiceReflector.GetOutputParameters(operation.EndMethod, true); this.returnParam = operation.EndMethod.ReturnParameter; } else if (this.syncMethod != null) { this.inParams = ServiceReflector.GetInputParameters(this.syncMethod, false); this.outParams = ServiceReflector.GetOutputParameters(this.syncMethod, false); this.returnParam = this.syncMethod.ReturnParameter; } if (this.formatter == null && (serializeRequest || deserializeReply)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ClientRuntimeRequiresFormatter0, this.name))); } }
internal ImmutableDispatchRuntime(DispatchRuntime dispatch) { _authenticationBehavior = AuthenticationBehavior.TryCreate(dispatch); _authorizationBehavior = AuthorizationBehavior.TryCreate(dispatch); _concurrency = new ConcurrencyBehavior(dispatch); _error = new ErrorBehavior(dispatch.ChannelDispatcher); _enableFaults = dispatch.EnableFaults; _inputSessionShutdownHandlers = EmptyArray <IInputSessionShutdown> .ToArray(dispatch.InputSessionShutdownHandlers); InstanceBehavior = new InstanceBehavior(dispatch, this); _isOnServer = dispatch.IsOnServer; _manualAddressing = dispatch.ManualAddressing; _messageInspectors = EmptyArray <IDispatchMessageInspector> .ToArray(dispatch.MessageInspectors); _securityImpersonation = SecurityImpersonationBehavior.CreateIfNecessary(dispatch); RequireClaimsPrincipalOnOperationContext = dispatch.RequireClaimsPrincipalOnOperationContext; _impersonateOnSerializingReply = dispatch.ImpersonateOnSerializingReply; _terminate = TerminatingOperationBehavior.CreateIfNecessary(dispatch); _thread = new ThreadBehavior(dispatch); ValidateMustUnderstand = dispatch.ValidateMustUnderstand; ParameterInspectorCorrelationOffset = (dispatch.MessageInspectors.Count + dispatch.MaxCallContextInitializers); _correlationCount = ParameterInspectorCorrelationOffset + dispatch.MaxParameterInspectors; DispatchOperationRuntime unhandled = new DispatchOperationRuntime(dispatch.UnhandledDispatchOperation, this); if (dispatch.OperationSelector == null) { ActionDemuxer demuxer = new ActionDemuxer(); for (int i = 0; i < dispatch.Operations.Count; i++) { DispatchOperation operation = dispatch.Operations[i]; DispatchOperationRuntime operationRuntime = new DispatchOperationRuntime(operation, this); demuxer.Add(operation.Action, operationRuntime); } demuxer.SetUnhandled(unhandled); _demuxer = demuxer; } else { CustomDemuxer demuxer = new CustomDemuxer(dispatch.OperationSelector); for (int i = 0; i < dispatch.Operations.Count; i++) { DispatchOperation operation = dispatch.Operations[i]; DispatchOperationRuntime operationRuntime = new DispatchOperationRuntime(operation, this); demuxer.Add(operation.Name, operationRuntime); } demuxer.SetUnhandled(unhandled); _demuxer = demuxer; } _processMessageNonCleanupError = new MessageRpcErrorHandler(ProcessMessageNonCleanupError); _processMessageCleanupError = new MessageRpcErrorHandler(ProcessMessageCleanupError); }
internal InstanceBehavior(DispatchRuntime dispatch, ImmutableDispatchRuntime immutableRuntime) { this.useSession = dispatch.ChannelDispatcher.Session; this.immutableRuntime = immutableRuntime; this.host = (dispatch.ChannelDispatcher == null) ? null : dispatch.ChannelDispatcher.Host; this.initializers = EmptyArray <IInstanceContextInitializer> .ToArray(dispatch.InstanceContextInitializers); this.provider = dispatch.InstanceProvider; this.singleton = dispatch.SingletonInstanceContext; this.transactionAutoCompleteOnSessionClose = dispatch.TransactionAutoCompleteOnSessionClose; this.releaseServiceInstanceOnTransactionComplete = dispatch.ReleaseServiceInstanceOnTransactionComplete; this.isSynchronized = (dispatch.ConcurrencyMode != ConcurrencyMode.Multiple); this.instanceContextProvider = dispatch.InstanceContextProvider; if (this.provider == null) { ConstructorInfo constructor = null; if (dispatch.Type != null) { constructor = InstanceBehavior.GetConstructor(dispatch.Type); } if (this.singleton == null) { if (dispatch.Type != null && (dispatch.Type.IsAbstract || dispatch.Type.IsInterface)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxServiceTypeNotCreatable))); } if (constructor == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxNoDefaultConstructor))); } } if (constructor != null) { if (this.singleton == null || !this.singleton.IsWellKnown) { InvokerUtil util = new InvokerUtil(); CreateInstanceDelegate creator = util.GenerateCreateInstanceDelegate(dispatch.Type, constructor); this.provider = new InstanceProvider(creator); } } } if (this.singleton != null) { this.singleton.Behavior = this; } }
internal ErrorBehavior(ChannelDispatcher channelDispatcher) { if (channelDispatcher?.ErrorHandlers == null) { Handlers = EmptyArray <IErrorHandler> .Allocate(0); } else { Handlers = EmptyArray <IErrorHandler> .ToArray(channelDispatcher.ErrorHandlers); } _debug = channelDispatcher.IncludeExceptionDetailInFaults; //isOnServer = channelDispatcher.IsOnServer; _isOnServer = true; _messageVersion = channelDispatcher.MessageVersion; }
internal InstanceBehavior(DispatchRuntime dispatch, ImmutableDispatchRuntime immutableRuntime) { this.immutableRuntime = immutableRuntime; initializers = EmptyArray <IInstanceContextInitializer> .ToArray(dispatch.InstanceContextInitializers); provider = dispatch.InstanceProvider; singleton = dispatch.SingletonInstanceContext; isSynchronized = (dispatch.ConcurrencyMode != ConcurrencyMode.Multiple); instanceContextProvider = dispatch.InstanceContextProvider; if (provider == null) { ConstructorInfo constructor = null; if (dispatch.Type != null) { constructor = InstanceBehavior.GetConstructor(dispatch.Type); } if (singleton == null) { if (dispatch.Type != null && (dispatch.Type.GetTypeInfo().IsAbstract || dispatch.Type.GetTypeInfo().IsInterface)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.SFxServiceTypeNotCreatable)); } if (constructor == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.SFxNoDefaultConstructor)); } } if (constructor != null) { if (singleton == null || !singleton.IsWellKnown) { InvokerUtil util = new InvokerUtil(); CreateInstanceDelegate creator = util.GenerateCreateInstanceDelegate(dispatch.Type, constructor); provider = new InstanceProvider(creator); } } } if (singleton != null) { singleton.Behavior = this; } }
internal ImmutableDispatchRuntime(DispatchRuntime dispatch) { _concurrency = new ConcurrencyBehavior(dispatch); _error = new ErrorBehavior(dispatch.ChannelDispatcher); EnableFaults = dispatch.EnableFaults; _instance = new InstanceBehavior(dispatch, this); ManualAddressing = dispatch.ManualAddressing; _messageInspectors = EmptyArray <IDispatchMessageInspector> .ToArray(dispatch.MessageInspectors); _terminate = TerminatingOperationBehavior.CreateIfNecessary(dispatch); _thread = new ThreadBehavior(dispatch); _sendAsynchronously = dispatch.ChannelDispatcher.SendAsynchronously; CorrelationCount = dispatch.MaxParameterInspectors; DispatchOperationRuntime unhandled = new DispatchOperationRuntime(dispatch.UnhandledDispatchOperation, this); ActionDemuxer demuxer = new ActionDemuxer(); for (int i = 0; i < dispatch.Operations.Count; i++) { DispatchOperation operation = dispatch.Operations[i]; DispatchOperationRuntime operationRuntime = new DispatchOperationRuntime(operation, this); demuxer.Add(operation.Action, operationRuntime); } demuxer.SetUnhandled(unhandled); _demuxer = demuxer; _processMessage1 = ProcessMessage1; _processMessage11 = ProcessMessage11; _processMessage2 = ProcessMessage2; _processMessage3 = ProcessMessage3; _processMessage31 = ProcessMessage31; _processMessage4 = ProcessMessage4; _processMessage41 = ProcessMessage41; _processMessage5 = ProcessMessage5; _processMessage6 = ProcessMessage6; _processMessage7 = ProcessMessage7; _processMessage8 = ProcessMessage8; _processMessage9 = ProcessMessage9; _processMessageCleanup = ProcessMessageCleanup; _processMessageCleanupError = ProcessMessageCleanupError; }
internal InstanceBehavior(DispatchRuntime dispatch, ImmutableDispatchRuntime immutableRuntime) { _immutableRuntime = immutableRuntime; _initializers = EmptyArray <IInstanceContextInitializer> .ToArray(dispatch.InstanceContextInitializers); _provider = dispatch.InstanceProvider; _singleton = dispatch.SingletonInstanceContext; InstanceContextProvider = dispatch.InstanceContextProvider; if (_provider == null) { bool hasDefaultConstructor = dispatch.Type != null && InvokerUtil.HasDefaultConstructor(dispatch.Type); if (_singleton == null) { if (dispatch.Type != null && (dispatch.Type.GetTypeInfo().IsAbstract || dispatch.Type.GetTypeInfo().IsInterface)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.SFxServiceTypeNotCreatable)); } if (!hasDefaultConstructor) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.SFxNoDefaultConstructor)); } } if (!hasDefaultConstructor) { if (_singleton == null || !_singleton.IsWellKnown) { CreateInstanceDelegate creator = InvokerUtil.GenerateCreateInstanceDelegate(dispatch.Type); _provider = new InstanceProvider(creator); } } } if (_singleton != null) { _singleton.Behavior = this; } }
internal DispatchOperationRuntime(DispatchOperation operation, ImmutableDispatchRuntime parent) { if (operation == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("operation"); } if (parent == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parent"); } if (operation.Invoker == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SRServiceModel.RuntimeRequiresInvoker0)); } _disposeParameters = ((operation.AutoDisposeParameters) && (!operation.HasNoDisposableParameters)); _parent = parent; _inspectors = EmptyArray <IParameterInspector> .ToArray(operation.ParameterInspectors); _faultFormatter = operation.FaultFormatter; _deserializeRequest = operation.DeserializeRequest; _serializeReply = operation.SerializeReply; _formatter = operation.Formatter; _invoker = operation.Invoker; _isSessionOpenNotificationEnabled = operation.IsSessionOpenNotificationEnabled; _action = operation.Action; _name = operation.Name; _replyAction = operation.ReplyAction; _isOneWay = operation.IsOneWay; if (_formatter == null && (_deserializeRequest || _serializeReply)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Format(SRServiceModel.DispatchRuntimeRequiresFormatter0, _name))); } }
//bool didTraceProcessMessage1 = false; //bool didTraceProcessMessage2 = false; //bool didTraceProcessMessage3 = false; //bool didTraceProcessMessage31 = false; //bool didTraceProcessMessage4 = false; //bool didTraceProcessMessage41 = false; internal ImmutableDispatchRuntime(DispatchRuntime dispatch) { //this.authenticationBehavior = AuthenticationBehavior.TryCreate(dispatch); //this.authorizationBehavior = AuthorizationBehavior.TryCreate(dispatch); concurrency = new ConcurrencyBehavior(dispatch); error = new ErrorBehavior(dispatch.ChannelDispatcher); enableFaults = dispatch.EnableFaults; inputSessionShutdownHandlers = EmptyArray <IInputSessionShutdown> .ToArray(dispatch.InputSessionShutdownHandlers); instance = new InstanceBehavior(dispatch, this); isOnServer = dispatch.IsOnServer; manualAddressing = dispatch.ManualAddressing; messageInspectors = EmptyArray <IDispatchMessageInspector> .ToArray(dispatch.MessageInspectors); //this.requestReplyCorrelator = new RequestReplyCorrelator(); //this.securityImpersonation = SecurityImpersonationBehavior.CreateIfNecessary(dispatch); //this.RequireClaimsPrincipalOnOperationContext = dispatch.RequireClaimsPrincipalOnOperationContext; //this.impersonateOnSerializingReply = dispatch.ImpersonateOnSerializingReply; terminate = TerminatingOperationBehavior.CreateIfNecessary(dispatch); thread = new ThreadBehavior(dispatch); ValidateMustUnderstand = dispatch.ValidateMustUnderstand; //this.ignoreTransactionFlow = dispatch.IgnoreTransactionMessageProperty; //this.transaction = TransactionBehavior.CreateIfNeeded(dispatch); //sendAsynchronously = dispatch.ChannelDispatcher.SendAsynchronously; ParameterInspectorCorrelationOffset = (dispatch.MessageInspectors.Count + dispatch.MaxCallContextInitializers); correlationCount = ParameterInspectorCorrelationOffset + dispatch.MaxParameterInspectors; DispatchOperationRuntime unhandled = new DispatchOperationRuntime(dispatch.UnhandledDispatchOperation, this); if (dispatch.OperationSelector == null) { ActionDemuxer demuxer = new ActionDemuxer(); for (int i = 0; i < dispatch.Operations.Count; i++) { DispatchOperation operation = dispatch.Operations[i]; DispatchOperationRuntime operationRuntime = new DispatchOperationRuntime(operation, this); demuxer.Add(operation.Action, operationRuntime); } demuxer.SetUnhandled(unhandled); this.demuxer = demuxer; } else { throw new PlatformNotSupportedException(); // CustomDemuxer demuxer = new CustomDemuxer(dispatch.OperationSelector); // for (int i = 0; i < dispatch.Operations.Count; i++) // { // DispatchOperation operation = dispatch.Operations[i]; // DispatchOperationRuntime operationRuntime = new DispatchOperationRuntime(operation, this); // demuxer.Add(operation.Name, operationRuntime); // } // demuxer.SetUnhandled(unhandled); // this.demuxer = demuxer; } //processMessage1 = new MessageRpcProcessor(ProcessMessage1); //processMessage11 = new MessageRpcProcessor(ProcessMessage11); //processMessage2 = new MessageRpcProcessor(ProcessMessage2); //processMessage3 = new MessageRpcProcessor(ProcessMessage3); //processMessage31 = new MessageRpcProcessor(ProcessMessage31); //processMessage4 = new MessageRpcProcessor(ProcessMessage4); //processMessage41 = new MessageRpcProcessor(ProcessMessage41); //processMessage5 = new MessageRpcProcessor(ProcessMessage5); //processMessage6 = new MessageRpcProcessor(ProcessMessage6); //processMessage7 = new MessageRpcProcessor(ProcessMessage7); //processMessage8 = new MessageRpcProcessor(ProcessMessage8); //processMessage9 = new MessageRpcProcessor(ProcessMessage9); //processMessageCleanup = new MessageRpcProcessor(ProcessMessageCleanup); processMessageNonCleanupError = new MessageRpcErrorHandler(ProcessMessageNonCleanupError); processMessageCleanupError = new MessageRpcErrorHandler(ProcessMessageCleanupError); }
//readonly bool isInsideTransactedReceiveScope; internal DispatchOperationRuntime(DispatchOperation operation, ImmutableDispatchRuntime parent) { if (operation == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(operation)); } if (parent == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(parent)); } if (operation.Invoker == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.RuntimeRequiresInvoker0)); } disposeParameters = ((operation.AutoDisposeParameters) && (!operation.HasNoDisposableParameters)); this.parent = parent; callContextInitializers = EmptyArray <ICallContextInitializer> .ToArray(operation.CallContextInitializers); inspectors = EmptyArray <IParameterInspector> .ToArray(operation.ParameterInspectors); faultFormatter = operation.FaultFormatter; impersonation = operation.Impersonation; deserializeRequest = operation.DeserializeRequest; serializeReply = operation.SerializeReply; formatter = operation.Formatter; invoker = operation.Invoker; try { isSynchronous = operation.Invoker.IsSynchronous; } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e); } isTerminating = operation.IsTerminating; isSessionOpenNotificationEnabled = operation.IsSessionOpenNotificationEnabled; action = operation.Action; name = operation.Name; releaseInstanceAfterCall = operation.ReleaseInstanceAfterCall; releaseInstanceBeforeCall = operation.ReleaseInstanceBeforeCall; replyAction = operation.ReplyAction; isOneWay = operation.IsOneWay; receiveContextAcknowledgementMode = operation.ReceiveContextAcknowledgementMode; bufferedReceiveEnabled = operation.BufferedReceiveEnabled; if (formatter == null && (deserializeRequest || serializeReply)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.DispatchRuntimeRequiresFormatter0, name))); } if ((operation.Parent.InstanceProvider == null) && (operation.Parent.Type != null)) { SyncMethodInvoker sync = invoker as SyncMethodInvoker; if (sync != null) { ValidateInstanceType(operation.Parent.Type, sync.Method); } //AsyncMethodInvoker async = this.invoker as AsyncMethodInvoker; //if (async != null) //{ // this.ValidateInstanceType(operation.Parent.Type, async.BeginMethod); // this.ValidateInstanceType(operation.Parent.Type, async.EndMethod); //} TaskMethodInvoker task = invoker as TaskMethodInvoker; if (task != null) { ValidateInstanceType(operation.Parent.Type, task.TaskMethod); } } }
internal DispatchOperationRuntime(DispatchOperation operation, ImmutableDispatchRuntime parent) { if (operation == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("operation"); } if (parent == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parent"); } if (operation.Invoker == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("RuntimeRequiresInvoker0"))); } this.disposeParameters = operation.AutoDisposeParameters && !operation.HasNoDisposableParameters; this.parent = parent; this.callContextInitializers = EmptyArray <ICallContextInitializer> .ToArray(operation.CallContextInitializers); this.inspectors = EmptyArray <IParameterInspector> .ToArray(operation.ParameterInspectors); this.faultFormatter = operation.FaultFormatter; this.impersonation = operation.Impersonation; this.deserializeRequest = operation.DeserializeRequest; this.serializeReply = operation.SerializeReply; this.formatter = operation.Formatter; this.invoker = operation.Invoker; try { this.isSynchronous = operation.Invoker.IsSynchronous; } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(exception); } this.isTerminating = operation.IsTerminating; this.action = operation.Action; this.name = operation.Name; this.releaseInstanceAfterCall = operation.ReleaseInstanceAfterCall; this.releaseInstanceBeforeCall = operation.ReleaseInstanceBeforeCall; this.replyAction = operation.ReplyAction; this.isOneWay = operation.IsOneWay; this.transactionAutoComplete = operation.TransactionAutoComplete; this.transactionRequired = operation.TransactionRequired; this.receiveContextAcknowledgementMode = operation.ReceiveContextAcknowledgementMode; this.bufferedReceiveEnabled = operation.BufferedReceiveEnabled; this.isInsideTransactedReceiveScope = operation.IsInsideTransactedReceiveScope; if ((this.formatter == null) && (this.deserializeRequest || this.serializeReply)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("DispatchRuntimeRequiresFormatter0", new object[] { this.name }))); } if ((operation.Parent.InstanceProvider == null) && (operation.Parent.Type != null)) { SyncMethodInvoker invoker = this.invoker as SyncMethodInvoker; if (invoker != null) { this.ValidateInstanceType(operation.Parent.Type, invoker.Method); } AsyncMethodInvoker invoker2 = this.invoker as AsyncMethodInvoker; if (invoker2 != null) { this.ValidateInstanceType(operation.Parent.Type, invoker2.BeginMethod); this.ValidateInstanceType(operation.Parent.Type, invoker2.EndMethod); } } }