Close() public method

Changes the reader's state to JsonReader.State.Closed.
public Close ( ) : void
return void
コード例 #1
0
ファイル: CommandReader.cs プロジェクト: intech/Checker
        private CmdRequest ReadRequest(NetworkStream stream)
        {
            CmdRequest request = null;
            JsonSerializer serializer = new JsonSerializer();
          
            using (JsonReader reader = new BsonReader(stream))
            {                                
                request = serializer.Deserialize<CmdRequest>(reader);
                reader.Close();
            }

            return request;
        }
コード例 #2
0
    public void CloseInput()
    {
      MemoryStream ms = new MemoryStream();
      BsonReader reader = new BsonReader(ms);

      Assert.IsTrue(ms.CanRead);
      reader.Close();
      Assert.IsFalse(ms.CanRead);

      ms = new MemoryStream();
      reader = new BsonReader(ms) { CloseInput = false };

      Assert.IsTrue(ms.CanRead);
      reader.Close();
      Assert.IsTrue(ms.CanRead);
    }
コード例 #3
0
ファイル: CommandServer.cs プロジェクト: intech/Checker
        private void InternalClientThread(object socketObject)
        {
            CmdServerReply reply = null;
            Socket clientSocket = socketObject as Socket;
            if (clientSocket != null)
            {
                try
                {
                    using (NetworkStream stream = new NetworkStream(clientSocket))
                    {
                        using (BsonReader reader = new BsonReader(stream))
                        {
                            JsonSerializer serializer = new JsonSerializer();
                            reply = serializer.Deserialize<CmdServerReply>(reader);

                            reader.Close();
                        }

                        stream.Close();
                    }
                }
                catch (Exception ex)
                {
                    reply = null;
                    Logger.AddError("Failed to receive reply from the checker", ex);
                }
            }

            if (reply != null)
            {
                SendCmdReply(reply);
            }
        }