Exemplo n.º 1
0
        public static void Test_DateTime_01()
        {
            //DateTimeSerializer dateTimeSerializer = new DateTimeSerializer(DateTimeSerializationOptions.LocalInstance);
            //BsonSerializer.RegisterSerializer(typeof(DateTime), dateTimeSerializer);

            //DateTime dt = new DateTime(2014, 8, 16, 22, 0, 0);
            Test_DateTime_Class_01 datetime = new Test_DateTime_Class_01 {
                datetime = new DateTime(2014, 8, 16, 22, 0, 0)
            };

            Trace.WriteLine("DateTime {0:dd-MM-yyyy HH:mm:ss K zz}", datetime.datetime);
            BsonDocument document = datetime.ToBsonDocument();

            Trace.WriteLine("DateTime.ToBsonDocument {0}", document.ToJson());
            Test_DateTime_Class_01 datetime2 = BsonSerializer.Deserialize <Test_DateTime_Class_01>(document);

            Trace.WriteLine("DateTime2 {0:dd-MM-yyyy HH:mm:ss K zz}", datetime2.datetime);
            Trace.WriteLine("DateTime == DateTime2 {0}", datetime.datetime == datetime2.datetime);
        }
Exemplo n.º 2
0
        public static void Test_DateTime_01()
        {
            //DateTimeSerializer dateTimeSerializer = new DateTimeSerializer(DateTimeSerializationOptions.LocalInstance);
            //BsonSerializer.RegisterSerializer(typeof(DateTime), dateTimeSerializer);

            //DateTime dt = new DateTime(2014, 8, 16, 22, 0, 0);
            Test_DateTime_Class_01 datetime = new Test_DateTime_Class_01 { datetime = new DateTime(2014, 8, 16, 22, 0, 0) };
            Trace.WriteLine("DateTime {0:dd-MM-yyyy HH:mm:ss K zz}", datetime.datetime);
            BsonDocument document = datetime.ToBsonDocument();
            Trace.WriteLine("DateTime.ToBsonDocument {0}", document.ToJson());
            Test_DateTime_Class_01 datetime2 = BsonSerializer.Deserialize<Test_DateTime_Class_01>(document);
            Trace.WriteLine("DateTime2 {0:dd-MM-yyyy HH:mm:ss K zz}", datetime2.datetime);
            Trace.WriteLine("DateTime == DateTime2 {0}", datetime.datetime == datetime2.datetime);
        }