Ejemplo n.º 1
0
        public void ApplyDispatchBehavior(OperationDescription operationDescription, DispatchOperation dispatchOperation)
        {
            Fx.Assert(operationDescription != null, "OperationDescription cannot be null!");
            Fx.Assert(dispatchOperation != null, "DispatchOperation cannot be null!");

            if (dispatchOperation.Formatter == null)
            {
                return;
            }

            this.formatter      = dispatchOperation.Formatter;
            this.faultFormatter = dispatchOperation.FaultFormatter;
            if (this.receives != null)
            {
                foreach (Receive receive in this.receives)
                {
                    receive.SetFormatter(this.formatter, this.faultFormatter, dispatchOperation.IncludeExceptionDetailInFaults);
                }
            }

            // Remove operation formatter from dispatch runtime
            dispatchOperation.Formatter          = null;
            dispatchOperation.DeserializeRequest = false;
            dispatchOperation.SerializeReply     = false;
        }
        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)));
            }
        }
        public void ApplyDispatchBehavior(OperationDescription operationDescription, DispatchOperation dispatchOperation)
        {
            Fx.Assert(operationDescription != null, "OperationDescription cannot be null!");
            Fx.Assert(dispatchOperation != null, "DispatchOperation cannot be null!");

            if (dispatchOperation.Formatter == null)
            {
                return;
            }

            this.formatter = dispatchOperation.Formatter;
            this.faultFormatter = dispatchOperation.FaultFormatter;
            if (this.receives != null)
            {
                foreach (Receive receive in this.receives)
                {
                    receive.SetFormatter(this.formatter, this.faultFormatter, dispatchOperation.IncludeExceptionDetailInFaults);
                }
            }

            // Remove operation formatter from dispatch runtime
            dispatchOperation.Formatter = null;
            dispatchOperation.DeserializeRequest = false;
            dispatchOperation.SerializeReply = false;
        }
Ejemplo n.º 4
0
        internal void SetFaultFormatter(IDispatchFaultFormatter faultFormatter, bool includeExceptionDetailInFaults)
        {
            Fx.Assert(this.responseFormatter != null, "ToReply cannot be null!");

            this.responseFormatter.FaultFormatter = faultFormatter;
            this.responseFormatter.IncludeExceptionDetailInFaults = includeExceptionDetailInFaults;
        }
Ejemplo n.º 5
0
 public void ApplyDispatchBehavior(OperationDescription operationDescription, DispatchOperation dispatchOperation)
 {
     if (dispatchOperation.Formatter != null)
     {
         this.formatter      = dispatchOperation.Formatter;
         this.faultFormatter = dispatchOperation.FaultFormatter;
         if (this.receives != null)
         {
             foreach (Receive receive in this.receives)
             {
                 receive.SetFormatter(this.formatter, this.faultFormatter, dispatchOperation.IncludeExceptionDetailInFaults);
             }
         }
         dispatchOperation.Formatter          = null;
         dispatchOperation.DeserializeRequest = false;
         dispatchOperation.SerializeReply     = false;
     }
 }
 public void ApplyDispatchBehavior(OperationDescription operationDescription, DispatchOperation dispatchOperation)
 {
     if (dispatchOperation.Formatter != null)
     {
         this.formatter = dispatchOperation.Formatter;
         this.faultFormatter = dispatchOperation.FaultFormatter;
         if (this.receives != null)
         {
             foreach (Receive receive in this.receives)
             {
                 receive.SetFormatter(this.formatter, this.faultFormatter, dispatchOperation.IncludeExceptionDetailInFaults);
             }
         }
         dispatchOperation.Formatter = null;
         dispatchOperation.DeserializeRequest = false;
         dispatchOperation.SerializeReply = false;
     }
 }
Ejemplo n.º 7
0
 internal void SetFormatter(IDispatchMessageFormatter formatter, IDispatchFaultFormatter faultFormatter, bool includeExceptionDetailInFaults)
 {
     this.requestFormatter.Formatter = formatter;
     if (this.followingReplies != null)
     {
         for (int i = 0; i < this.followingReplies.Count; i++)
         {
             this.followingReplies[i].SetFormatter(formatter);
         }
     }
     if (this.followingFaults != null)
     {
         for (int j = 0; j < this.followingFaults.Count; j++)
         {
             this.followingFaults[j].SetFaultFormatter(faultFormatter, includeExceptionDetailInFaults);
         }
     }
 }
Ejemplo n.º 8
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(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)));
            }
        }
 internal WebFaultFormatter(IDispatchFaultFormatter faultFormatter)
 {
     this.faultFormatter = faultFormatter;
 }
        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);
                }
            }
        }
        //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);
                }
            }
        }
Ejemplo n.º 12
0
        internal void SetFormatter(IDispatchMessageFormatter formatter, IDispatchFaultFormatter faultFormatter, bool includeExceptionDetailInFaults)
        {
            if (this.requestFormatter != null)
            {
                this.requestFormatter.Formatter = formatter;
            }

            if (this.followingReplies != null) 
            {
                for (int i = 0; i < this.followingReplies.Count; i++)
                {
                    this.followingReplies[i].SetFormatter(formatter);
                }
            }

            if (this.followingFaults != null)
            {
                for (int i = 0; i < this.followingFaults.Count; i++)
                {
                    this.followingFaults[i].SetFaultFormatter(faultFormatter, includeExceptionDetailInFaults);
                }
            }
        }
Ejemplo n.º 13
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);
                }
            }
        }
Ejemplo n.º 14
0
        internal void SetFaultFormatter(IDispatchFaultFormatter faultFormatter, bool includeExceptionDetailInFaults)
        {
            Fx.Assert(this.responseFormatter != null, "ToReply cannot be null!");

            this.responseFormatter.FaultFormatter = faultFormatter;
            this.responseFormatter.IncludeExceptionDetailInFaults = includeExceptionDetailInFaults;
        }
 internal void SetFaultFormatter(IDispatchFaultFormatter faultFormatter, bool includeExceptionDetailInFaults)
 {
     this.responseFormatter.FaultFormatter = faultFormatter;
     this.responseFormatter.IncludeExceptionDetailInFaults = includeExceptionDetailInFaults;
 }
 internal WebFaultFormatter(IDispatchFaultFormatter faultFormatter)
 {
     this.faultFormatter = faultFormatter;
 }