public static void DecodeFramingFault(Microsoft.ServiceBus.Channels.ClientFramingDecoder decoder, Microsoft.ServiceBus.Channels.IConnection connection, Uri via, string contentType, ref Microsoft.ServiceBus.Common.TimeoutHelper timeoutHelper)
        {
            Microsoft.ServiceBus.Channels.ConnectionUpgradeHelper.ValidateReadingFaultString(decoder);
            int num = 0;

            byte[] numArray = Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.Utility.AllocateByteArray(256);
            int    num1     = connection.Read(numArray, num, (int)numArray.Length, timeoutHelper.RemainingTime());

            while (num1 > 0)
            {
                int num2 = decoder.Decode(numArray, num, num1);
                num  = num + num2;
                num1 = num1 - num2;
                if (decoder.CurrentState == Microsoft.ServiceBus.Channels.ClientFramingDecoderState.Fault)
                {
                    Microsoft.ServiceBus.Channels.ConnectionUtilities.CloseNoThrow(connection, timeoutHelper.RemainingTime());
                    throw Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility.ThrowHelperError(Microsoft.ServiceBus.Channels.FaultStringDecoder.GetFaultException(decoder.Fault, via.ToString(), contentType));
                }
                if (decoder.CurrentState != Microsoft.ServiceBus.Channels.ClientFramingDecoderState.ReadingFaultString)
                {
                    throw Fx.AssertAndThrow("invalid framing client state machine");
                }
                if (num1 != 0)
                {
                    continue;
                }
                num  = 0;
                num1 = connection.Read(numArray, num, (int)numArray.Length, timeoutHelper.RemainingTime());
            }
            throw Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility.ThrowHelperError(decoder.CreatePrematureEOFException());
        }
 public static bool ValidatePreambleResponse(byte[] buffer, int count, Microsoft.ServiceBus.Channels.ClientFramingDecoder decoder, Uri via)
 {
     if (count == 0)
     {
         ExceptionUtility exceptionUtility = Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility;
         string           serverRejectedSessionPreamble = Resources.ServerRejectedSessionPreamble;
         object[]         objArray = new object[] { via };
         throw exceptionUtility.ThrowHelperError(new ProtocolException(Microsoft.ServiceBus.SR.GetString(serverRejectedSessionPreamble, objArray), decoder.CreatePrematureEOFException()));
     }
     while (decoder.Decode(buffer, 0, count) == 0)
     {
     }
     if (decoder.CurrentState != Microsoft.ServiceBus.Channels.ClientFramingDecoderState.Start)
     {
         return(false);
     }
     return(true);
 }
 private static bool ValidateUpgradeResponse(byte[] buffer, int count, Microsoft.ServiceBus.Channels.ClientFramingDecoder decoder)
 {
     if (count == 0)
     {
         throw Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MessageSecurityException(Microsoft.ServiceBus.SR.GetString(Resources.ServerRejectedUpgradeRequest, new object[0]), decoder.CreatePrematureEOFException()));
     }
     while (decoder.Decode(buffer, 0, count) == 0)
     {
     }
     if (decoder.CurrentState != Microsoft.ServiceBus.Channels.ClientFramingDecoderState.UpgradeResponse)
     {
         return(false);
     }
     return(true);
 }