当前位置: 首页>>代码示例>>C#>>正文


C# MessageRpc.AbortRequestContext方法代码示例

本文整理汇总了C#中System.ServiceModel.Dispatcher.MessageRpc.AbortRequestContext方法的典型用法代码示例。如果您正苦于以下问题:C# MessageRpc.AbortRequestContext方法的具体用法?C# MessageRpc.AbortRequestContext怎么用?C# MessageRpc.AbortRequestContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.ServiceModel.Dispatcher.MessageRpc的用法示例。


在下文中一共展示了MessageRpc.AbortRequestContext方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessMessageCleanup

        private void ProcessMessageCleanup(ref MessageRpc rpc)
        {
            Fx.Assert(
                !object.ReferenceEquals(rpc.ErrorProcessor, _processMessageCleanupError),
                "ProcessMessageCleanup run twice on the same MessageRpc!");
            rpc.ErrorProcessor = _processMessageCleanupError;

            bool replyWasSent = false;

            if (rpc.CanSendReply)
            {
                if (_sendAsynchronously)
                {
                    replyWasSent = this.EndReply(ref rpc);
                }
                else
                {
                    replyWasSent = rpc.SuccessfullySendReply;
                }
            }

            try
            {
                try
                {
                    if (rpc.DidDeserializeRequestBody)
                    {
                        rpc.Request.Close();
                    }
                }
                catch (Exception e)
                {
                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }
                    _error.HandleError(e);
                }

                rpc.DisposeParameters(false); //Dispose all input/output/return parameters

                if (rpc.FaultInfo.IsConsideredUnhandled)
                {
                    if (!replyWasSent)
                    {
                        rpc.AbortRequestContext();
                        rpc.AbortChannel();
                    }
                    else
                    {
                        rpc.CloseRequestContext();
                        rpc.CloseChannel();
                    }
                    rpc.AbortInstanceContext();
                }
                else
                {
                    if (rpc.RequestContextThrewOnReply)
                    {
                        rpc.AbortRequestContext();
                    }
                    else
                    {
                        rpc.CloseRequestContext();
                    }
                }


                if ((rpc.Reply != null) && (rpc.Reply != rpc.ReturnParameter))
                {
                    try
                    {
                        rpc.Reply.Close();
                    }
                    catch (Exception e)
                    {
                        if (Fx.IsFatal(e))
                        {
                            throw;
                        }
                        _error.HandleError(e);
                    }
                }

                if ((rpc.FaultInfo.Fault != null) && (rpc.FaultInfo.Fault.State != MessageState.Closed))
                {
                    // maybe ProvideFault gave a Message, but then BeforeSendReply replaced it
                    // in that case, we need to close the one from ProvideFault
                    try
                    {
                        rpc.FaultInfo.Fault.Close();
                    }
                    catch (Exception e)
                    {
                        if (Fx.IsFatal(e))
                        {
                            throw;
                        }
                        _error.HandleError(e);
                    }
//.........这里部分代码省略.........
开发者ID:weshaggard,项目名称:wcf,代码行数:101,代码来源:ImmutableDispatchRuntime.cs

示例2: ProcessMessageCleanup

        // Logic for knowing when to close stuff:
        //
        // ASSUMPTIONS:
        //   Closing a stream over a message also closes the message.
        //   Closing a message over a stream does not close the stream.
        //     (OperationStreamProvider.ReleaseStream is no-op)
        //
        // This is a table of what should be disposed in what cases.
        // The rows represent the type of parameter to the method and
        // whether we are disposing parameters or not.  The columns
        // are for the inputs vs. the outputs.  The cells contain the
        // values that need to be Disposed.  M^P means that exactly
        // one of the message and parameter needs to be disposed,
        // since they refer to the same object.
        //
        //                               Request           Reply
        //               Message   |     M or P      |     M or P
        //     Dispose   Stream    |     P           |     M and P
        //               Params    |     M and P     |     M and P
        //                         |                 |
        //               Message   |     none        |     none
        //   NoDispose   Stream    |     none        |     M
        //               Params    |     M           |     M
        //
        // By choosing to dispose the parameter in both of the "M or P"
        // cases, the logic needed to generate this table is:
        //
        // CloseRequestMessage = IsParams
        // CloseRequestParams  = rpc.Operation.DisposeParameters
        // CloseReplyMessage   = rpc.Operation.SerializeReply
        // CloseReplyParams    = rpc.Operation.DisposeParameters
        //
        // IsParams can be calculated based on whether the request
        // message was consumed after deserializing but before calling
        // the user.  This is stored as rpc.DidDeserializeRequestBody.
        //
        void ProcessMessageCleanup(ref MessageRpc rpc)
        {
            Fx.Assert(
                !object.ReferenceEquals(rpc.ErrorProcessor, this.processMessageCleanupError),
                "ProcessMessageCleanup run twice on the same MessageRpc!");
            rpc.ErrorProcessor = this.processMessageCleanupError;

            bool replyWasSent = false;

            if (rpc.CanSendReply)
            {
                if (this.sendAsynchronously)
                {
                    replyWasSent = this.EndReply(ref rpc);
                }
                else
                {
                    replyWasSent = rpc.SuccessfullySendReply;
                }
            }

            try
            {
                try
                {
                    if (rpc.DidDeserializeRequestBody)
                    {
                        rpc.Request.Close();
                    }
                }
                catch (Exception e)
                {
                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }
                    this.error.HandleError(e);
                }

                if (rpc.HostingProperty != null)
                {
                    try
                    {
                        rpc.HostingProperty.Close();
                    }
                    catch (Exception e)
                    {
                        if (Fx.IsFatal(e))
                        {
                            throw;
                        }
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperFatal(e.Message, e);
                    }
                }

                // for wf, wf owns the lifetime of the request message. So in that case, we should not dispose the inputs
                IManualConcurrencyOperationInvoker manualInvoker = rpc.Operation.Invoker as IManualConcurrencyOperationInvoker;
                rpc.DisposeParameters(manualInvoker != null && manualInvoker.OwnsFormatter); //Dispose all input/output/return parameters

                if (rpc.FaultInfo.IsConsideredUnhandled)
                {
                    if (!replyWasSent)
                    {
                        rpc.AbortRequestContext();
//.........这里部分代码省略.........
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:101,代码来源:ImmutableDispatchRuntime.cs

示例3: ProcessMessageCleanup

 private void ProcessMessageCleanup(ref MessageRpc rpc)
 {
     rpc.ErrorProcessor = this.processMessageCleanupError;
     bool successfullySendReply = false;
     if (rpc.CanSendReply)
     {
         if (this.sendAsynchronously)
         {
             successfullySendReply = this.EndReply(ref rpc);
         }
         else
         {
             successfullySendReply = rpc.SuccessfullySendReply;
         }
     }
     try
     {
         try
         {
             if (rpc.DidDeserializeRequestBody)
             {
                 rpc.Request.Close();
             }
         }
         catch (Exception exception)
         {
             if (Fx.IsFatal(exception))
             {
                 throw;
             }
             this.error.HandleError(exception);
         }
         if (rpc.HostingProperty != null)
         {
             try
             {
                 rpc.HostingProperty.Close();
             }
             catch (Exception exception2)
             {
                 if (Fx.IsFatal(exception2))
                 {
                     throw;
                 }
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperFatal(exception2.Message, exception2);
             }
         }
         IManualConcurrencyOperationInvoker invoker = rpc.Operation.Invoker as IManualConcurrencyOperationInvoker;
         rpc.DisposeParameters((invoker != null) && invoker.OwnsFormatter);
         if (rpc.FaultInfo.IsConsideredUnhandled)
         {
             if (!successfullySendReply)
             {
                 rpc.AbortRequestContext();
                 rpc.AbortChannel();
             }
             else
             {
                 rpc.CloseRequestContext();
                 rpc.CloseChannel();
             }
             rpc.AbortInstanceContext();
         }
         else if (rpc.RequestContextThrewOnReply)
         {
             rpc.AbortRequestContext();
         }
         else
         {
             rpc.CloseRequestContext();
         }
         if ((rpc.Reply != null) && (rpc.Reply != rpc.ReturnParameter))
         {
             try
             {
                 rpc.Reply.Close();
             }
             catch (Exception exception3)
             {
                 if (Fx.IsFatal(exception3))
                 {
                     throw;
                 }
                 this.error.HandleError(exception3);
             }
         }
         if ((rpc.FaultInfo.Fault != null) && (rpc.FaultInfo.Fault.State != MessageState.Closed))
         {
             try
             {
                 rpc.FaultInfo.Fault.Close();
             }
             catch (Exception exception4)
             {
                 if (Fx.IsFatal(exception4))
                 {
                     throw;
                 }
                 this.error.HandleError(exception4);
             }
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:ImmutableDispatchRuntime.cs


注:本文中的System.ServiceModel.Dispatcher.MessageRpc.AbortRequestContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。