1
 public ProtobufSerializer(IWebSerializableTypeHandler webSerializableTypeHandler, bool useTypeHashCode)
    {
        RuntimeTypeModel.Default.Add(typeof(Project), true).SetSurrogate(typeof(Project));
    }

    private CommandData ReadCommandData(ProtoReader reader)
    {
        int header = -1;
        var data = new Data();
        while ((header = reader.ReadFieldHeader()) > 0)
        {
            switch (header)
            {
                case 2:
                    var typeName = reader.ReadString();
                    var type = myTypeHandler.GetWebSerializableType(typeName);
                    data.DataType = type;
                    break;
                case 3:
                    data.CorrelationId = reader.ReadString();
                    break;
                case 4:
                    data.CommandId = reader.ReadString();
                    break;
                case 5:
                    data.Flags = (ExecuteFlags)reader.ReadInt32();
                    break;
                case 6:
                    data.CommandState = (CommandStates)reader.ReadInt32();
                    break;
                case 7:
                    data.IsHighPriority = reader.ReadBoolean();
                    break;
                case 8:
                    Project data = new Project();
                    **data = (Project)ProtoReader.ReadObject(data.Data,-1,reader);**
                    break;
                default:
                    reader.SkipField();
                    break;
            }
        }
        return data;
    }

我正在使用 ProtoWriter 和 ProtoReader 进行序列化和反序列化。使用 ProtoReader.ReadObject(data.Data,-1,reader) 时出现错误。我错过了什么吗?

4

0 回答 0