public void deserialize(InputArchive archive, string tag) { results = new List <OpResult>(); archive.startRecord(tag); MultiHeader h = new MultiHeader(); ((Record)h).deserialize(archive, tag); while (!h.getDone()) { ZooDefs.OpCode opcode = EnumUtil <ZooDefs.OpCode> .DefinedCast(h.get_Type()); switch (opcode) { case ZooDefs.OpCode.create: CreateResponse cr = new CreateResponse(); ((Record)cr).deserialize(archive, tag); results.Add(new OpResult.CreateResult(cr.getPath())); break; case ZooDefs.OpCode.delete: results.Add(new OpResult.DeleteResult()); break; case ZooDefs.OpCode.setData: SetDataResponse sdr = new SetDataResponse(); ((Record)sdr).deserialize(archive, tag); results.Add(new OpResult.SetDataResult(sdr.getStat())); break; case ZooDefs.OpCode.check: results.Add(new OpResult.CheckResult()); break; case ZooDefs.OpCode.error: //FIXME: need way to more cleanly serialize/deserialize exceptions ErrorResponse er = new ErrorResponse(); ((Record)er).deserialize(archive, tag); results.Add(new OpResult.ErrorResult(er.getErr())); break; default: throw new IOException("Invalid type " + h.get_Type() + " in MultiResponse"); } ((Record)h).deserialize(archive, tag); } archive.endRecord(tag); }
public void deserialize(InputArchive archive, string tag) { archive.startRecord(tag); MultiHeader h = new MultiHeader(); ((Record)h).deserialize(archive, tag); while (!h.getDone()) { ZooDefs.OpCode opCode = EnumUtil <ZooDefs.OpCode> .DefinedCast(h.get_Type()); switch (opCode) { case ZooDefs.OpCode.create: CreateRequest cr = new CreateRequest(); ((Record)cr).deserialize(archive, tag); add(Op.create(cr.getPath(), cr.getData(), cr.getAcl(), cr.getFlags())); break; case ZooDefs.OpCode.delete: DeleteRequest dr = new DeleteRequest(); ((Record)dr).deserialize(archive, tag); add(Op.delete(dr.getPath(), dr.getVersion())); break; case ZooDefs.OpCode.setData: SetDataRequest sdr = new SetDataRequest(); ((Record)sdr).deserialize(archive, tag); add(Op.setData(sdr.getPath(), sdr.getData(), sdr.getVersion())); break; case ZooDefs.OpCode.check: CheckVersionRequest cvr = new CheckVersionRequest(); ((Record)cvr).deserialize(archive, tag); add(Op.check(cvr.getPath(), cvr.getVersion())); break; default: throw new IOException("Invalid type of op"); } ((Record)h).deserialize(archive, tag); } archive.endRecord(tag); }