internal static void UnlockInstanceBeforeCallout(OperationContext operationContext) { if (operationContext != null && operationContext.IsServiceReentrant) { ConcurrencyBehavior.UnlockInstance(operationContext.InstanceContext); } }
internal void UnlockInstance(ref MessageRpc rpc) { if (concurrencyMode != ConcurrencyMode.Multiple) { ConcurrencyBehavior.UnlockInstance(rpc.InstanceContext); } }
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 ChannelHandler(MessageVersion messageVersion, IChannelBinder binder, ServiceThrottle throttle, ServiceDispatcher serviceDispatcher, bool wasChannelThrottled, SessionIdleManager idleManager) { ChannelDispatcher channelDispatcher = serviceDispatcher.ChannelDispatcher; _serviceDispatcher = serviceDispatcher; _messageVersion = messageVersion; _isManualAddressing = channelDispatcher.ManualAddressing; _binder = binder; _throttle = throttle; _wasChannelThrottled = wasChannelThrottled; _host = channelDispatcher.Host; _duplexBinder = binder as DuplexChannelBinder; _hasSession = binder.HasSession; _isConcurrent = ConcurrencyBehavior.IsConcurrent(channelDispatcher, _hasSession); // TODO: Work out if MultipleReceiveBinder is necessary //if (channelDispatcher.MaxPendingReceives > 1) //{ // // We need to preserve order if the ChannelHandler is not concurrent. // this.binder = new MultipleReceiveBinder( // this.binder, // channelDispatcher.MaxPendingReceives, // !this.isConcurrent); //} if (channelDispatcher.BufferedReceiveEnabled) { _binder = new BufferedReceiveBinder(_binder); } _idleManager = idleManager; if (_binder.HasSession) { _sessionOpenNotification = _binder.Channel.GetProperty <SessionOpenNotification>(); _needToCreateSessionOpenNotificationMessage = _sessionOpenNotification != null && _sessionOpenNotification.IsEnabled; } //_requestInfo = new RequestInfo(this); // TODO: Wire up lifetime management in place of listener state //if (this.listener.State == CommunicationState.Opened) //{ _serviceDispatcher.ChannelDispatcher.Channels.IncrementActivityCount(); _incrementedActivityCountInConstructor = true; //} }
//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); }