示例#1
0
        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);
        }