Ejemplo n.º 1
0
        public static void TestZippedStream(int len, int ziplevel)
        {
            DateTime t1, t2;
            TimeSpan dt;


            Foo o = new Foo();

            o.Fill(len);


            System.IO.FileStream zipoutfile = System.IO.File.Create(@"C:\temp\xmlteststream01.xml.zip");
            ZipOutputStream      ZipStream  = new ZipOutputStream(zipoutfile);
            ZipEntry             ZipEntry   = new ZipEntry("Table/Table1.xml");

            ZipStream.PutNextEntry(ZipEntry);
            ZipStream.SetLevel(ziplevel);

            XmlStreamSerializationInfo info = new XmlStreamSerializationInfo();

            t1 = DateTime.Now;
            info.BeginWriting(ZipStream);
            info.AddValue("FooNode", o);
            info.EndWriting();
            ZipStream.Finish();
            ZipStream.Close();
            zipoutfile.Close();

            t2 = DateTime.Now;
            dt = t2 - t1;
            Console.WriteLine("Document saved, duration {0}.", dt);


            t1 = DateTime.Now;
            ZipFile zipfile = new ZipFile(@"C:\temp\xmlteststream01.xml.zip");

            System.IO.Stream             zipinpstream = zipfile.GetInputStream(new ZipEntry("Table/Table1.xml"));
            XmlStreamDeserializationInfo info3        = new XmlStreamDeserializationInfo();

            info3.BeginReading(zipinpstream);
            Foo o3 = (Foo)info3.GetValue(null);

            info3.EndReading();
            zipinpstream.Close();
            zipfile.Close();
            t2 = DateTime.Now;
            dt = t2 - t1;
            Console.WriteLine("Document restored, duration {0}.", dt);
            o3.EnsureEquality(len);
        }
Ejemplo n.º 2
0
        public static void TestUnzippedStream(int len, XmlArrayEncoding encoding)
        {
            DateTime t1, t2;
            TimeSpan dt;


            Foo o = new Foo();

            o.Fill(len);


            System.IO.FileStream       outfile = System.IO.File.Create(@"C:\temp\xmlteststream01.xml");
            XmlStreamSerializationInfo info    = new XmlStreamSerializationInfo();

            info.DefaultArrayEncoding = encoding;
            t1 = DateTime.Now;
            info.BeginWriting(outfile);
            info.AddValue("FooNode", o);
            info.EndWriting();
            outfile.Close();

            t2 = DateTime.Now;
            dt = t2 - t1;
            Console.WriteLine("Document saved, duration {0}.", dt);


            t1 = DateTime.Now;
            System.IO.FileStream         inpstream = System.IO.File.Open(@"C:\temp\xmlteststream01.xml", System.IO.FileMode.Open);
            XmlStreamDeserializationInfo info3     = new XmlStreamDeserializationInfo();

            info3.BeginReading(inpstream);
            Foo o3 = (Foo)info3.GetValue(null);

            info3.EndReading();
            t2 = DateTime.Now;
            dt = t2 - t1;
            Console.WriteLine("Document restored, duration {0}.", dt);
            NUnit.Framework.Assertion.Assert(o3.EnsureEquality(len));
        }
Ejemplo n.º 3
0
    public static void TestZippedStream(int len, int ziplevel)
    {
      DateTime t1, t2;
      TimeSpan dt;

      Foo o = new Foo();
      o.Fill(len);

      System.IO.FileStream zipoutfile = System.IO.File.Create(@"C:\temp\xmlteststream01.xml.zip");
      ZipOutputStream ZipStream = new ZipOutputStream(zipoutfile);
      ZipEntry ZipEntry = new ZipEntry("Table/Table1.xml");
      ZipStream.PutNextEntry(ZipEntry);
      ZipStream.SetLevel(ziplevel);

      XmlStreamSerializationInfo info = new XmlStreamSerializationInfo();
      t1 = DateTime.Now;
      info.BeginWriting(ZipStream);
      info.AddValue("FooNode",o);
      info.EndWriting();
      ZipStream.Finish();
      ZipStream.Close();
      zipoutfile.Close();

      t2 = DateTime.Now;
      dt = t2-t1;
      Console.WriteLine("Document saved, duration {0}.",dt);

      t1 = DateTime.Now;
      ZipFile zipfile = new ZipFile(@"C:\temp\xmlteststream01.xml.zip");
      System.IO.Stream zipinpstream = zipfile.GetInputStream(new ZipEntry("Table/Table1.xml"));
      XmlStreamDeserializationInfo info3 = new XmlStreamDeserializationInfo();
      info3.BeginReading(zipinpstream);
      Foo o3 = (Foo)info3.GetValue(null);
      info3.EndReading();
      zipinpstream.Close();
      zipfile.Close();
      t2 = DateTime.Now;
      dt = t2-t1;
      Console.WriteLine("Document restored, duration {0}.",dt);
      o3.EnsureEquality(len);
    }
Ejemplo n.º 4
0
 protected virtual void EhDeserializationInfoCreated(XmlStreamDeserializationInfo info)
 {
     // store in the deserialization info a rename dictionary which stores key-value pairs of original color set name and new color set name
     info.PropertyDictionary.Add(DeserializationRenameDictionaryKey, new Dictionary <string, string>());
 }
Ejemplo n.º 5
0
    public static void TestUnzippedStream(int len, XmlArrayEncoding encoding)
    {
      DateTime t1, t2;
      TimeSpan dt;

      Foo o = new Foo();
      o.Fill(len);

      System.IO.FileStream outfile = System.IO.File.Create(@"C:\temp\xmlteststream01.xml");
      XmlStreamSerializationInfo info = new XmlStreamSerializationInfo();
      info.DefaultArrayEncoding = encoding;
      t1 = DateTime.Now;
      info.BeginWriting(outfile);
      info.AddValue("FooNode",o);
      info.EndWriting();
      outfile.Close();

      t2 = DateTime.Now;
      dt = t2-t1;
      Console.WriteLine("Document saved, duration {0}.",dt);

      t1 = DateTime.Now;
      System.IO.FileStream inpstream = System.IO.File.Open(@"C:\temp\xmlteststream01.xml",System.IO.FileMode.Open);
      XmlStreamDeserializationInfo info3 = new XmlStreamDeserializationInfo();
      info3.BeginReading(inpstream);
      Foo o3 = (Foo)info3.GetValue(null);
      info3.EndReading();
      t2 = DateTime.Now;
      dt = t2-t1;
      Console.WriteLine("Document restored, duration {0}.",dt);
      NUnit.Framework.Assertion.Assert(o3.EnsureEquality(len));
    }