小编Wil*_*der的帖子

字节数组上的protobuf-net OverwriteList

我正在尝试通过protobuf-net发送IPEndpoint,我观察到的是当将4字节数组反序列化为IP4地址时,设置代码接收8字节的值.包含orignal地址的四个字节,以及包含已序列化地址的另外4个字节.通过逐步执行代码,我已经能够确认在调用Deserialize时,它首先读取字节,然后设置它们的字节.

在做了一些阅读后,我了解了OverwriteList,并且如下例所示,我已将其设置为true.但是,设置器仍然提供8字节值.

有谁知道我做错了什么?

当与protobuf-net r480,Visual Studio 2010一起用作.Net 4.0控制台应用程序时,此示例代码应抛出异常.

using ProtoBuf;
using System.Net;
using System.IO;

namespace ConsoleApplication1
{

    [ProtoContract]
    class AddressOWner
    {
        private IPEndPoint endpoint;

        public AddressOWner() 
        { endpoint = new IPEndPoint(new IPAddress(new byte[] {8,8,8,8}), 0); }

        public AddressOWner(IPEndPoint newendpoint)
        { this.endpoint = newendpoint; }

        [ProtoMember(1, OverwriteList=true)]
        public byte[] AddressBytes
        {
            get { return endpoint.Address.GetAddressBytes(); }
            set { endpoint.Address = new IPAddress(value); }
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            AddressOWner ao = new AddressOWner(new IPEndPoint(new IPAddress(new byte[] …

c# protobuf-net

6
推荐指数
1
解决办法
1329
查看次数

在设计时将TDataSet嵌入到表单中

I am looking for a way to provide a ListSource to a TDBLookupComboBox in delphi without having an actual table on the database server to draw that list from. The DataField for the Combo Box is a 1 character field that contains a coded value such as 'A' = 'Drivers License', 'B' = 'Passport', 'C' = 'Library Card', etc. That is to say that the table only contains A, B, or C. The application is responsible for Displaying 'Drivers License' …

delphi data-binding tdataset

3
推荐指数
1
解决办法
390
查看次数

标签 统计

c# ×1

data-binding ×1

delphi ×1

protobuf-net ×1

tdataset ×1