GetNetworkStream() private méthode

private GetNetworkStream ( ) : Stream
Résultat Stream
        public void Receive()
        {
            Reader = new BinaryReader(Connection.GetNetworkStream());
            var reader = Reader;

            Status    = (ResponseStatus)reader.ReadByte();
            SessionId = reader.ReadInt32EndianAware();

            if (Status == ResponseStatus.ERROR)
            {
                string exceptionString = "";

                byte followByte = reader.ReadByte();

                while (followByte == 1)
                {
                    int exceptionClassLength = reader.ReadInt32EndianAware();
                    exceptionString += System.Text.Encoding.Default.GetString(reader.ReadBytes(exceptionClassLength)) + ": ";

                    int exceptionMessageLength = reader.ReadInt32EndianAware();

                    // don't read exception message string if it's null
                    if (exceptionMessageLength != -1)
                    {
                        exceptionString += System.Text.Encoding.Default.GetString(reader.ReadBytes(exceptionMessageLength)) + "\n";
                    }

                    followByte = reader.ReadByte();
                }

                throw new OException(OExceptionType.Operation, exceptionString);
            }
        }
        public void Receive()
        {
            Reader = new BinaryReader(Connection.GetNetworkStream());
            var reader = Reader;

            Status    = (ResponseStatus)reader.ReadByte();
            SessionId = reader.ReadInt32EndianAware();

            //if (Connection.UseTokenBasedSession && Connection.ProtocolVersion > 26)
            //{
            //    var size = reader.ReadInt32EndianAware();
            //    Token = reader.ReadBytesRequired(size);
            //}

            if (Status == ResponseStatus.ERROR)
            {
                string exceptionString = "";

                byte followByte = reader.ReadByte();

                while (followByte == 1)
                {
                    int    exceptionClassLength = reader.ReadInt32EndianAware();
                    byte[] exceptionSringByte   = reader.ReadBytes(exceptionClassLength);
                    exceptionString += System.Text.Encoding.UTF8.GetString(exceptionSringByte, 0, exceptionSringByte.Length) + ": ";

                    int exceptionMessageLength = reader.ReadInt32EndianAware();

                    // don't read exception message string if it's null
                    if (exceptionMessageLength != -1)
                    {
                        byte[] exceptionByte = reader.ReadBytes(exceptionMessageLength);
                        exceptionString += System.Text.Encoding.UTF8.GetString(exceptionByte, 0, exceptionByte.Length) + "\n";
                    }

                    followByte = reader.ReadByte();
                }
                if (OClient.ProtocolVersion >= 19)
                {
                    int serializedVersionLength = reader.ReadInt32EndianAware();
                    var buffer = reader.ReadBytes(serializedVersionLength);
                }
                throw new OException(OExceptionType.Operation, exceptionString);
            }
        }