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)));
            }
        }
 public static void CreateIfRequired(ImmutableDispatchRuntime dispatchRuntime, ref MessageRpc messageRpc)
 {
     if (messageRpc.Operation.ReceiveContextAcknowledgementMode != ReceiveContextAcknowledgementMode.ManualAcknowledgement)
     {
         ReceiveContext property = null;
         if (!ReceiveContext.TryGet(messageRpc.Request, out property))
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxReceiveContextPropertyMissing", new object[] { typeof(ReceiveContext).Name })));
         }
         messageRpc.Request.Properties.Remove(ReceiveContext.Name);
         if ((messageRpc.Operation.ReceiveContextAcknowledgementMode == ReceiveContextAcknowledgementMode.AutoAcknowledgeOnReceive) && !messageRpc.Operation.TransactionRequired)
         {
             AcknowledgementCompleteCallbackState state = new AcknowledgementCompleteCallbackState {
                 DispatchRuntime = dispatchRuntime,
                 Rpc             = messageRpc
             };
             IAsyncResult result = new AcknowledgementCompleteAsyncResult(property, TimeSpan.MaxValue, ref messageRpc, null, handleEndComplete, state);
             if (result.CompletedSynchronously)
             {
                 AcknowledgementCompleteAsyncResult.End(result);
             }
         }
         else
         {
             messageRpc.ReceiveContext = new ReceiveContextRPCFacet(property);
         }
     }
 }
 public static void CreateIfRequired(ImmutableDispatchRuntime dispatchRuntime, ref MessageRpc messageRpc)
 {
     if (messageRpc.Operation.ReceiveContextAcknowledgementMode != ReceiveContextAcknowledgementMode.ManualAcknowledgement)
     {
         ReceiveContext property = null;
         if (!ReceiveContext.TryGet(messageRpc.Request, out property))
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxReceiveContextPropertyMissing", new object[] { typeof(ReceiveContext).Name })));
         }
         messageRpc.Request.Properties.Remove(ReceiveContext.Name);
         if ((messageRpc.Operation.ReceiveContextAcknowledgementMode == ReceiveContextAcknowledgementMode.AutoAcknowledgeOnReceive) && !messageRpc.Operation.TransactionRequired)
         {
             AcknowledgementCompleteCallbackState state = new AcknowledgementCompleteCallbackState {
                 DispatchRuntime = dispatchRuntime,
                 Rpc = messageRpc
             };
             IAsyncResult result = new AcknowledgementCompleteAsyncResult(property, TimeSpan.MaxValue, ref messageRpc, null, handleEndComplete, state);
             if (result.CompletedSynchronously)
             {
                 AcknowledgementCompleteAsyncResult.End(result);
             }
         }
         else
         {
             messageRpc.ReceiveContext = new ReceiveContextRPCFacet(property);
         }
     }
 }
        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(SR.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(SR.Format(SR.DispatchRuntimeRequiresFormatter0, _name)));
            }
        }
示例#5
0
 internal void InvalidateRuntime()
 {
     lock (this.ThisLock)
     {
         this.shared.ThrowIfImmutable();
         this.runtime = null;
     }
 }
示例#6
0
 internal void InvalidateRuntime()
 {
     lock (ThisLock)
     {
         _shared.ThrowIfImmutable();
         _runtime = null;
     }
 }
示例#7
0
        internal ImmutableDispatchRuntime GetRuntime()
        {
            ImmutableDispatchRuntime runtime = this.runtime;

            if (runtime != null)
            {
                return(runtime);
            }
            return(this.GetRuntimeCore());
        }
示例#8
0
 private ImmutableDispatchRuntime GetRuntimeCore()
 {
     lock (this.ThisLock)
     {
         if (this.runtime == null)
         {
             this.runtime = new ImmutableDispatchRuntime(this);
         }
         return(this.runtime);
     }
 }
 public void Complete(ImmutableDispatchRuntime dispatchRuntime, ref MessageRpc rpc, TimeSpan timeout, Transaction transaction)
 {
     AcknowledgementCompleteCallbackState state = new AcknowledgementCompleteCallbackState {
         DispatchRuntime = dispatchRuntime,
         Rpc = rpc
     };
     IAsyncResult result = new AcknowledgementCompleteAsyncResult(this.receiveContext, timeout, ref rpc, transaction, handleEndComplete, state);
     if (result.CompletedSynchronously)
     {
         AcknowledgementCompleteAsyncResult.End(result);
     }
 }
示例#10
0
        internal ImmutableDispatchRuntime GetRuntime()
        {
            ImmutableDispatchRuntime runtime = _runtime;

            if (runtime != null)
            {
                return(runtime);
            }
            else
            {
                return(GetRuntimeCore());
            }
        }
        public void Complete(ImmutableDispatchRuntime dispatchRuntime, ref MessageRpc rpc, TimeSpan timeout, Transaction transaction)
        {
            AcknowledgementCompleteCallbackState state = new AcknowledgementCompleteCallbackState {
                DispatchRuntime = dispatchRuntime,
                Rpc             = rpc
            };
            IAsyncResult result = new AcknowledgementCompleteAsyncResult(this.receiveContext, timeout, ref rpc, transaction, handleEndComplete, state);

            if (result.CompletedSynchronously)
            {
                AcknowledgementCompleteAsyncResult.End(result);
            }
        }
示例#12
0
        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 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;
            }
        }
        //Called from ProcessMessage1
        //ManualAcknowledgementMode : No-Op.
        //Non-transacted V1 Operation : Remove RC; RC.Complete;(Will pause RPC if truly async)
        //Else : Create and Attach RCFacet to MessageRPC.
        public static void CreateIfRequired(ImmutableDispatchRuntime dispatchRuntime, ref MessageRpc messageRpc)
        {
            if (messageRpc.Operation.ReceiveContextAcknowledgementMode == ReceiveContextAcknowledgementMode.ManualAcknowledgement)
            {
                //Manual mode, user owns the acknowledgement.
                return;
            }

            //Retrieve RC from request and ensure it is removed from Message.
            ReceiveContext receiveContext = null;

            if (!ReceiveContext.TryGet(messageRpc.Request, out receiveContext))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                          new InvalidOperationException(
                              SR.GetString(SR.SFxReceiveContextPropertyMissing,
                                           typeof(ReceiveContext).Name)));
            }
            messageRpc.Request.Properties.Remove(ReceiveContext.Name);

            if (messageRpc.Operation.ReceiveContextAcknowledgementMode == ReceiveContextAcknowledgementMode.AutoAcknowledgeOnReceive)
            {
                if (!messageRpc.Operation.TransactionRequired)
                {
                    //Attempt to complete the ReceiveContext.
                    //Async Result Ensures RPC is paused if it goes ASYNC.
                    IAsyncResult result = new AcknowledgementCompleteAsyncResult(
                        receiveContext,
                        TimeSpan.MaxValue,
                        ref messageRpc,
                        null,
                        handleEndComplete,
                        new AcknowledgementCompleteCallbackState
                    {
                        DispatchRuntime = dispatchRuntime,
                        Rpc             = messageRpc
                    });

                    if (result.CompletedSynchronously)
                    {
                        AcknowledgementCompleteAsyncResult.End(result);
                    }
                    return;
                }
            }
            //We have to create a Facet for acknowledgement at later stage.
            messageRpc.ReceiveContext = new ReceiveContextRPCFacet(receiveContext);
        }
        //Called from ProcessMessage1
        //ManualAcknowledgementMode : No-Op.
        //Non-transacted V1 Operation : Remove RC; RC.Complete;(Will pause RPC if truly async)
        //Else : Create and Attach RCFacet to MessageRPC.
        public static void CreateIfRequired(ImmutableDispatchRuntime dispatchRuntime, ref MessageRpc messageRpc)
        {
            if (messageRpc.Operation.ReceiveContextAcknowledgementMode == ReceiveContextAcknowledgementMode.ManualAcknowledgement)
            {
                //Manual mode, user owns the acknowledgement.
                return;
            }

            //Retrieve RC from request and ensure it is removed from Message.
            ReceiveContext receiveContext = null;
            if (!ReceiveContext.TryGet(messageRpc.Request, out receiveContext))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                    new InvalidOperationException(
                    SR.GetString(SR.SFxReceiveContextPropertyMissing,
                    typeof(ReceiveContext).Name)));
            }
            messageRpc.Request.Properties.Remove(ReceiveContext.Name);

            if (messageRpc.Operation.ReceiveContextAcknowledgementMode == ReceiveContextAcknowledgementMode.AutoAcknowledgeOnReceive)
            {
                if (!messageRpc.Operation.TransactionRequired)
                {
                    //Attempt to complete the ReceiveContext.
                    //Async Result Ensures RPC is paused if it goes ASYNC.
                    IAsyncResult result = new AcknowledgementCompleteAsyncResult(
                        receiveContext,
                        TimeSpan.MaxValue,
                        ref messageRpc,
                        null,
                        handleEndComplete,
                        new AcknowledgementCompleteCallbackState
                        {
                            DispatchRuntime = dispatchRuntime,
                            Rpc = messageRpc
                        });

                    if (result.CompletedSynchronously)
                    {
                        AcknowledgementCompleteAsyncResult.End(result);
                    }
                    return;
                }
            }
            //We have to create a Facet for acknowledgement at later stage.
            messageRpc.ReceiveContext = new ReceiveContextRPCFacet(receiveContext);
        }
        //Called from ProcessMessage31.
        //Mode is TransactedOperation && !ManualAcknowledgement
        //Will pause RPC if Complete is truly Async.
        public void Complete(ImmutableDispatchRuntime dispatchRuntime, ref MessageRpc rpc, TimeSpan timeout, Transaction transaction)
        {
            Fx.Assert(transaction != null, "Cannot reach here with null transaction");
            //Async Result Ensures the RPC is paused if the request goes Async.
            IAsyncResult result = new AcknowledgementCompleteAsyncResult(
                this.receiveContext,
                timeout,
                ref rpc,
                transaction,
                handleEndComplete,
                new AcknowledgementCompleteCallbackState
                {
                    DispatchRuntime = dispatchRuntime,
                    Rpc = rpc
                });

            if (result.CompletedSynchronously)
            {
                AcknowledgementCompleteAsyncResult.End(result);
            }
        }
        //Called from ProcessMessage31.
        //Mode is TransactedOperation && !ManualAcknowledgement
        //Will pause RPC if Complete is truly Async.
        public void Complete(ImmutableDispatchRuntime dispatchRuntime, ref MessageRpc rpc, TimeSpan timeout, Transaction transaction)
        {
            Fx.Assert(transaction != null, "Cannot reach here with null transaction");
            //Async Result Ensures the RPC is paused if the request goes Async.
            IAsyncResult result = new AcknowledgementCompleteAsyncResult(
                this.receiveContext,
                timeout,
                ref rpc,
                transaction,
                handleEndComplete,
                new AcknowledgementCompleteCallbackState
            {
                DispatchRuntime = dispatchRuntime,
                Rpc             = rpc
            });

            if (result.CompletedSynchronously)
            {
                AcknowledgementCompleteAsyncResult.End(result);
            }
        }
        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)));
            }
        }
 // This constructor should be used when we are making a copy from the already initialized RPCCorrelationCallbackMessageProperty
 public RpcCorrelationCallbackMessageProperty(RpcCorrelationCallbackMessageProperty rpcCallbackMessageProperty)
     : base(rpcCallbackMessageProperty)
 {
     this.innerCallback = rpcCallbackMessageProperty.innerCallback;
     this.runtime = rpcCallbackMessageProperty.runtime;
     this.rpc = rpcCallbackMessageProperty.rpc;
 }
示例#20
0
        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);
                }
            }
        }
 // This constructor should be used when creating the RPCCorrelationMessageproperty the first time
 // Here we copy the data & the needed data from the original callback
 public RpcCorrelationCallbackMessageProperty(CorrelationCallbackMessageProperty innerCallback,
     ImmutableDispatchRuntime runtime, ref MessageRpc rpc)
     : base(innerCallback)
 {
     this.innerCallback = innerCallback;
     this.runtime = runtime;
     this.rpc = rpc;
 }
示例#22
0
 internal InstanceBehavior(DispatchRuntime dispatch, ImmutableDispatchRuntime immutableRuntime)
 {
     _provider = dispatch.InstanceProvider;
     _instanceContextProvider = dispatch.InstanceContextProvider;
 }
        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(SR.GetString(SR.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 e)
            {
                if (Fx.IsFatal(e))
                {
                    throw;
                }
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperCallback(e);
            }
            this.isTerminating = operation.IsTerminating;
            this.isSessionOpenNotificationEnabled = operation.IsSessionOpenNotificationEnabled;
            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 && (deserializeRequest || serializeReply))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.DispatchRuntimeRequiresFormatter0, this.name)));
            }

            if ((operation.Parent.InstanceProvider == null) && (operation.Parent.Type != null))
            {
                SyncMethodInvoker sync = this.invoker as SyncMethodInvoker;
                if (sync != null)
                {
                    this.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 = this.invoker as TaskMethodInvoker;
                if (task != null)
                {
                    this.ValidateInstanceType(operation.Parent.Type, task.TaskMethod);
                }
            }
        }
 public RpcCorrelationCallbackMessageProperty(ImmutableDispatchRuntime.RpcCorrelationCallbackMessageProperty rpcCallbackMessageProperty) : base(rpcCallbackMessageProperty)
 {
     this.innerCallback = rpcCallbackMessageProperty.innerCallback;
     this.runtime = rpcCallbackMessageProperty.runtime;
     this.rpc = rpcCallbackMessageProperty.rpc;
 }
示例#25
0
        internal DispatchOperationRuntime GetOperation(ref Message message)
        {
            ImmutableDispatchRuntime runtime = GetRuntime();

            return(runtime.GetOperation(ref message));
        }
 internal InstanceBehavior(DispatchRuntime dispatch, ImmutableDispatchRuntime immutableRuntime)
 {
     _provider = dispatch.InstanceProvider;
     _instanceContextProvider = dispatch.InstanceContextProvider;
 }