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


C# BsonWriter.Close方法代码示例

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


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

示例1: SendCmdRequest

        public bool SendCmdRequest(CmdRequest request)
        {
            Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            try
            {
                socket.Connect("127.0.0.1", Port);
                using (NetworkStream stream = new NetworkStream(socket))
                {
                    using (BsonWriter writer = new BsonWriter(stream))
                    {
                        JsonSerializer serializer = new JsonSerializer();
                        serializer.Serialize(writer, request);
                        writer.Flush();
                        writer.Close();
                    }
                   
                    stream.Close();
                }
            }
            catch(Exception ex)
            {
                Logger.AddError(string.Format("Failed to send cmd request to checker with port = {0}", Port), ex);
                return false;
            }

            return true;
        }
开发者ID:intech,项目名称:Checker,代码行数:28,代码来源:ThreadProcess.cs

示例2: Serialize

 protected virtual byte[] Serialize(object obj)
 {
     using (var ms = new MemoryStream())
     {
         var bw = new BsonWriter(ms);
         Serializer.Serialize(bw, obj);
         bw.Close();
         return ms.ToArray();
     }
 }
开发者ID:holajan,项目名称:dotvvm,代码行数:10,代码来源:ViewModelProtectionHelper.cs

示例3: CloseOutput

        public void CloseOutput()
        {
            MemoryStream ms = new MemoryStream();
            BsonWriter writer = new BsonWriter(ms);

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

            ms = new MemoryStream();
            writer = new BsonWriter(ms) { CloseOutput = false };

            Assert.IsTrue(ms.CanRead);
            writer.Close();
            Assert.IsTrue(ms.CanRead);
        }
开发者ID:b-bot-108,项目名称:brain-bot-111-b-bot-110-BND,代码行数:16,代码来源:BsonWriterTests.cs

示例4: WriteReply

 private void WriteReply(NetworkStream stream, CmdServerReply reply)
 {
     JsonSerializer serializer = new JsonSerializer();
     using (BsonWriter writer = new BsonWriter(stream))
     {
         serializer.Serialize(writer, reply);
         writer.Flush();
         writer.Close();
     }
 }
开发者ID:intech,项目名称:Checker,代码行数:10,代码来源:CommandReader.cs


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