Ejemplo n.º 1
0
 internal DispatchRuntime(ClientRuntime proxyRuntime, SharedRuntimeState shared)
     : this(shared)
 {
     ClientRuntime            = proxyRuntime ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(proxyRuntime));
     _instanceProvider        = new CallbackInstanceProvider();
     _channelDispatcher       = new ChannelDispatcher(shared);
     _instanceContextProvider = InstanceContextProviderBase.GetProviderForMode(InstanceContextMode.PerSession, this);
     Fx.Assert(!shared.IsOnServer, "Client constructor called on server?");
 }
Ejemplo n.º 2
0
 internal DispatchRuntime(System.ServiceModel.Dispatcher.ClientRuntime proxyRuntime, SharedRuntimeState shared) : this(shared)
 {
     if (proxyRuntime == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("proxyRuntime");
     }
     this.proxyRuntime            = proxyRuntime;
     this.instanceProvider        = new CallbackInstanceProvider();
     this.channelDispatcher       = new System.ServiceModel.Dispatcher.ChannelDispatcher(shared);
     this.instanceContextProvider = InstanceContextProviderBase.GetProviderForMode(InstanceContextMode.PerSession, this);
 }
 internal bool CanUnload(InstanceContext instanceContext)
 {
     if (InstanceContextProviderBase.IsProviderSingleton(this.instanceContextProvider))
     {
         return(false);
     }
     if ((!InstanceContextProviderBase.IsProviderPerCall(this.instanceContextProvider) && !InstanceContextProviderBase.IsProviderSessionful(this.instanceContextProvider)) && !this.instanceContextProvider.IsIdle(instanceContext))
     {
         this.instanceContextProvider.NotifyIdle(InstanceContext.NotifyIdleCallback, instanceContext);
         return(false);
     }
     return(true);
 }
Ejemplo n.º 4
0
        internal bool CanUnload(InstanceContext instanceContext)
        {
            if (InstanceContextProviderBase.IsProviderSingleton(this.instanceContextProvider))
            {
                return(false);
            }

            if (InstanceContextProviderBase.IsProviderPerCall(this.instanceContextProvider) ||
                InstanceContextProviderBase.IsProviderSessionful(this.instanceContextProvider))
            {
                return(true);
            }

            //User provided InstanceContextProvider. Call the provider to check for idle.
            if (!this.instanceContextProvider.IsIdle(instanceContext))
            {
                this.instanceContextProvider.NotifyIdle(InstanceContext.NotifyIdleCallback, instanceContext);
                return(false);
            }
            return(true);
        }
Ejemplo n.º 5
0
        private void TransferChannelFromPendingList(ref MessageRpc rpc)
        {
            if (rpc.Channel.IsPending)
            {
                rpc.Channel.IsPending = false;

                ChannelDispatcher        channelDispatcher = rpc.Channel.ChannelDispatcher;
                IInstanceContextProvider provider          = _instance.InstanceContextProvider;

                if (!InstanceContextProviderBase.IsProviderSessionful(provider) &&
                    !InstanceContextProviderBase.IsProviderSingleton(provider))
                {
                    IChannel proxy = rpc.Channel.Proxy as IChannel;
                    if (!rpc.InstanceContext.IncomingChannels.Contains(proxy))
                    {
                        channelDispatcher.Channels.Add(proxy);
                    }
                }

                channelDispatcher.PendingChannels.Remove(rpc.Channel.Binder.Channel);
            }
        }
Ejemplo n.º 6
0
        internal MessageRpc(RequestContext requestContext, Message request, DispatchOperationRuntime operation,
                            ServiceChannel channel, ServiceHostBase host, ChannelHandler channelHandler, bool cleanThread,
                            OperationContext operationContext, InstanceContext instanceContext, EventTraceActivity eventTraceActivity)
        {
            Fx.Assert((operationContext != null), "System.ServiceModel.Dispatcher.MessageRpc.MessageRpc(), operationContext == null");
            Fx.Assert(channelHandler != null, "System.ServiceModel.Dispatcher.MessageRpc.MessageRpc(), channelHandler == null");

            this.Activity                   = null;
            this.EventTraceActivity         = eventTraceActivity;
            this.AsyncResult                = null;
            this.CanSendReply               = true;
            this.Channel                    = channel;
            this.channelHandler             = channelHandler;
            this.Correlation                = EmptyArray.Allocate(operation.Parent.CorrelationCount);
            this.CorrelationCallback        = null;
            this.DidDeserializeRequestBody  = false;
            this.TransactionMessageProperty = null;
            this.TransactedBatchContext     = null;
            this.Error              = null;
            this.ErrorProcessor     = null;
            this.FaultInfo          = new ErrorHandlerFaultInfo(request.Version.Addressing.DefaultFaultAction);
            this.HasSecurityContext = false;
            this.Host     = host;
            this.Instance = null;
            this.MessageRpcOwnsInstanceContextThrottle = false;
            this.NextProcessor        = null;
            this.NotUnderstoodHeaders = null;
            this.Operation            = operation;
            this.OperationContext     = operationContext;
            this.paused                     = false;
            this.ParametersDisposed         = false;
            this.ReceiveContext             = null;
            this.Request                    = request;
            this.RequestContext             = requestContext;
            this.RequestContextThrewOnReply = false;
            this.SuccessfullySendReply      = false;
            this.RequestVersion             = request.Version;
            this.Reply = null;
            this.ReplyTimeoutHelper              = new TimeoutHelper();
            this.SecurityContext                 = null;
            this.InstanceContext                 = instanceContext;
            this.SuccessfullyBoundInstance       = false;
            this.SuccessfullyIncrementedActivity = false;
            this.SuccessfullyLockedInstance      = false;
            this.switchedThreads                 = !cleanThread;
            this.transaction                = null;
            this.InputParameters            = null;
            this.OutputParameters           = null;
            this.ReturnParameter            = null;
            this.isInstanceContextSingleton = InstanceContextProviderBase.IsProviderSingleton(this.Channel.DispatchRuntime.InstanceContextProvider);
            this.invokeContinueGate         = null;

            if (!operation.IsOneWay && !operation.Parent.ManualAddressing)
            {
                this.RequestID   = request.Headers.MessageId;
                this.ReplyToInfo = new RequestReplyCorrelator.ReplyToInfo(request);
            }
            else
            {
                this.RequestID   = null;
                this.ReplyToInfo = new RequestReplyCorrelator.ReplyToInfo();
            }

            this.HostingProperty = AspNetEnvironment.Current.GetHostingProperty(request, true);

            if (DiagnosticUtility.ShouldUseActivity)
            {
                this.Activity = TraceUtility.ExtractActivity(this.Request);
            }

            if (DiagnosticUtility.ShouldUseActivity || TraceUtility.ShouldPropagateActivity)
            {
                this.ResponseActivityId = ActivityIdHeader.ExtractActivityId(this.Request);
            }
            else
            {
                this.ResponseActivityId = Guid.Empty;
            }

            this.InvokeNotification = new MessageRpcInvokeNotification(this.Activity, this.channelHandler);

            if (this.EventTraceActivity == null && FxTrace.Trace.IsEnd2EndActivityTracingEnabled)
            {
                if (this.Request != null)
                {
                    this.EventTraceActivity = EventTraceActivityHelper.TryExtractActivity(this.Request, true);
                }
            }
        }