예제 #1
0
        public static void Test_TelechargementPlus_PostDetail_Serialize(TelechargementPlus_PostDetail post)
        {
            Trace.WriteLine("Serialize");
            var document1 = post.ToBsonDocument();

            Trace.WriteLine(document1.zToJson());
            Trace.WriteLine("Deserialize");
            post = BsonSerializer.Deserialize <TelechargementPlus_PostDetail>(document1);
            Trace.WriteLine("Serialize");
            var document2 = post.ToBsonDocument();

            Trace.WriteLine(document2.zToJson());
            if (document1 == document2)
            {
                Trace.WriteLine("documents are identical");
            }
            else
            {
                Trace.WriteLine("documents are different");
            }
        }
예제 #2
0
        public static void Test_TelechargementPlus_PostDetail_Serialize_05(bool executePostToBsonDocument, string url, object key, string database, string collectionName, string itemName = "download", string server = null, bool reload = false, bool loadImage = false)
        {
            Trace.WriteLine("Test_TelechargementPlus_PostDetail_Serialize_05");
            TelechargementPlus_PostDetail post = LoadPostDetailFromWeb(url, reload, loadImage);

            // très bizarre si post.ToBsonDocument(); pas d'erreur la désérialisation marche
            // si pas de post.ToBsonDocument(); erreur la désérialisation ne marche pas
            if (executePostToBsonDocument)
            {
                post.ToBsonDocument();
            }
            BsonDocument document2 = ReadMongoDocument(database, collectionName, key, itemName, server);

            Trace.Write("try Deserialize document2 to TelechargementPlus_PostDetail ");
            TryDeserializeDocument <TelechargementPlus_PostDetail>(document2);
        }
예제 #3
0
        public static void Test_TelechargementPlus_PostDetail_Serialize_04(string url, object key, string database, string collectionName, string itemName = "download", string server = null, bool reload = false, bool loadImage = false)
        {
            Trace.WriteLine("Test_TelechargementPlus_PostDetail_Serialize_04");
            TelechargementPlus_PostDetail post = LoadPostDetailFromWeb(url, reload, loadImage);
            BsonDocument document1             = post.ToBsonDocument();
            BsonDocument document2             = ReadMongoDocument(database, collectionName, key, itemName, server);

            Trace.Write("try Deserialize document2 to TelechargementPlus_PostDetail ");
            TryDeserializeDocument <TelechargementPlus_PostDetail>(document2);

            //return;

            ////TelechargementPlus_PostDetail post2 = BsonSerializer.Deserialize<TelechargementPlus_PostDetail>(document2);

            //if (document1.CompareTo(document2) == 0)
            //    Trace.WriteLine("document1 and document2 are identical");
            //else
            //    Trace.WriteLine("document1 and document2 are different");

            ////Trace.WriteLine("document1");
            ////Trace.WriteLine(document1.zToJson());
            ////Trace.WriteLine("document2");
            ////Trace.WriteLine(document2.zToJson());

            //string file1 = @"c:\pib\dev_data\exe\runsource\test\log\document1.txt";
            //Trace.WriteLine("export document1 to \"{0}\"", file1);
            //zfile.WriteFile(file1, document1.zToJson());
            //string file2 = @"c:\pib\dev_data\exe\runsource\test\log\document2.txt";
            //Trace.WriteLine("export document1 to \"{0}\"", file2);
            //zfile.WriteFile(file2, document2.zToJson());

            //Trace.Write("try Deserialize document1 to TelechargementPlus_PostDetail ");
            //TryDeserializeDocument<TelechargementPlus_PostDetail>(document1);
            //Trace.Write("try Deserialize document2 to TelechargementPlus_PostDetail ");
            //TryDeserializeDocument<TelechargementPlus_PostDetail>(document2);

            ////TelechargementPlus_PostDetail post1 = BsonSerializer.Deserialize<TelechargementPlus_PostDetail>(document1);
            ////TelechargementPlus_PostDetail post2 = BsonSerializer.Deserialize<TelechargementPlus_PostDetail>(document2);
        }