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


C# IBsonReader.ReadDateTime方法代码示例

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


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

示例1: TestDateTimeStrictIso8601

 public void TestDateTimeStrictIso8601()
 {
     var json = "{ \"$date\" : \"1970-01-01T00:00:00Z\" }";
     using (_bsonReader = new JsonReader(json))
     {
         Assert.Equal(BsonType.DateTime, _bsonReader.ReadBsonType());
         Assert.Equal(0, _bsonReader.ReadDateTime());
         Assert.Equal(BsonReaderState.Initial, _bsonReader.State);
     }
     var expected = "{ \"$date\" : 0 }"; // it's still not ISO8601 on the way out
     var jsonSettings = new JsonWriterSettings { OutputMode = JsonOutputMode.Strict };
     Assert.Equal(expected, BsonSerializer.Deserialize<DateTime>(json).ToJson(jsonSettings));
 }
开发者ID:mfidemraizer,项目名称:mongo-csharp-driver,代码行数:13,代码来源:JsonReaderTests.cs

示例2: TestDateTimeStrict

 public void TestDateTimeStrict()
 {
     var json = "{ \"$date\" : 0 }";
     using (_bsonReader = new JsonReader(json))
     {
         Assert.Equal(BsonType.DateTime, _bsonReader.ReadBsonType());
         Assert.Equal(0, _bsonReader.ReadDateTime());
         Assert.Equal(BsonReaderState.Initial, _bsonReader.State);
     }
     var jsonSettings = new JsonWriterSettings { OutputMode = JsonOutputMode.Strict };
     Assert.Equal(json, BsonSerializer.Deserialize<DateTime>(json).ToJson(jsonSettings));
 }
开发者ID:mfidemraizer,项目名称:mongo-csharp-driver,代码行数:12,代码来源:JsonReaderTests.cs

示例3: TestDateTimeMaxBson

 public void TestDateTimeMaxBson()
 {
     var json = "new Date(9223372036854775807)";
     using (_bsonReader = new JsonReader(json))
     {
         Assert.Equal(BsonType.DateTime, _bsonReader.ReadBsonType());
         Assert.Equal(9223372036854775807, _bsonReader.ReadDateTime());
         Assert.Equal(BsonReaderState.Initial, _bsonReader.State);
     }
     Assert.Equal(json, BsonSerializer.Deserialize<BsonDateTime>(json).ToJson());
 }
开发者ID:mfidemraizer,项目名称:mongo-csharp-driver,代码行数:11,代码来源:JsonReaderTests.cs

示例4: TestDateTimeShell

 public void TestDateTimeShell(string json, long expectedResult, string canonicalJson)
 {
     using (_bsonReader = new JsonReader(json))
     {
         Assert.Equal(BsonType.DateTime, _bsonReader.ReadBsonType());
         Assert.Equal(expectedResult, _bsonReader.ReadDateTime());
         Assert.Equal(BsonReaderState.Initial, _bsonReader.State);
     }
     var jsonSettings = new JsonWriterSettings { OutputMode = JsonOutputMode.Shell };
     Assert.Equal(canonicalJson, BsonSerializer.Deserialize<DateTime>(json).ToJson(jsonSettings));
 }
开发者ID:mfidemraizer,项目名称:mongo-csharp-driver,代码行数:11,代码来源:JsonReaderTests.cs

示例5: TestDateTimeShell

 public void TestDateTimeShell()
 {
     var json = "ISODate(\"1970-01-01T00:00:00Z\")";
     using (_bsonReader = new JsonReader(json))
     {
         Assert.AreEqual(BsonType.DateTime, _bsonReader.ReadBsonType());
         Assert.AreEqual(0, _bsonReader.ReadDateTime());
         Assert.AreEqual(BsonReaderState.Initial, _bsonReader.State);
     }
     var jsonSettings = new JsonWriterSettings { OutputMode = JsonOutputMode.Shell };
     Assert.AreEqual(json, BsonSerializer.Deserialize<DateTime>(json).ToJson(jsonSettings));
 }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:12,代码来源:JsonReaderTests.cs


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