public override void ParseFromRaw(ChunkRaw c) { XmlSerializer serializerObj = new XmlSerializer(typeof(DummyClass)); obj = (DummyClass)serializerObj.Deserialize(new MemoryStream(c.Data)); }
public void SetObj(DummyClass o) { this.obj = o; }
public PngChunkSERI(ImageInfo info) : base(ID, info) { obj = new DummyClass(); }
public override void CloneDataFromRead(PngChunk other) { PngChunkSERI otherx = (PngChunkSERI)other; this.obj = otherx.obj; // shallow clone, we could implement other copying }
public static void testWrite(string src, string target) { // for writing is not necesary to register DummyClass c = new DummyClass(); c.name = "Hernán"; c.age = 45; PngReader pngr = FileHelper.CreatePngReader(src); PngWriter pngw = FileHelper.CreatePngWriter(target, pngr.ImgInfo, true); pngw.CopyChunksFirst(pngr, ChunkCopyBehaviour.COPY_ALL_SAFE); PngChunkSERI mychunk = new PngChunkSERI(pngw.ImgInfo); mychunk.SetObj(c); mychunk.Priority = true; // if we want it to be written as soon as possible pngw.GetChunksList().Queue(mychunk); for (int row = 0; row < pngr.ImgInfo.Rows; row++) { ImageLine l1 = pngr.ReadRow(row); pngw.WriteRow(l1, row); } pngw.CopyChunksLast(pngr, ChunkCopyBehaviour.COPY_ALL); pngr.End(); pngw.End(); Console.Out.WriteLine("Done. Writen : " + target); }