2
我想序列化List<T>
但獲取空文件和List<T>
將不會序列化。我沒有得到任何的異常,並宣讀protobuf網手動,這是我想要序列的所有成員都標有[ProtoContract]
和[ProtoMember]
atributesprotobuf網不序列化列表<T>
public void Save()
{
using (var outputStream = File.Create(SettingsModel.QueueListDataFile))
{
Serializer.Serialize(outputStream, QueueList);
}
}
[Serializable]
[ProtoContract]
public class QueueList : SafeList<QueueItem>
{
}
[Serializable]
[ProtoContract]
public class SafeList<T> : SafeLock
{
[ProtoMember(1)]
private static readonly List<T> ItemsList = new List<T>();
}
[Serializable]
[ProtoContract]
public class QueueItem
{
[ProtoMember(1)]
public string SessionId { get; set; }
[ProtoMember(2)]
public string Email { get; set; }
[ProtoMember(3)]
public string Ip { get; set; }
}