本文整理汇总了C#中Newtonsoft.Json.Bson.BsonReader.Close方法的典型用法代码示例。如果您正苦于以下问题:C# BsonReader.Close方法的具体用法?C# BsonReader.Close怎么用?C# BsonReader.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Newtonsoft.Json.Bson.BsonReader
的用法示例。
在下文中一共展示了BsonReader.Close方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadRequest
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: CloseInput
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: InternalClientThread
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);
}
}