protobuf-net

Does protobuf net support object graphs of shared references inside list/arrays?

百般思念 提交于 2019-12-07 15:43:01
问题 It seems that protobuf net doesn't support AsReference for lists/array and also AsReference for objects inside list/array. Will this be supported in final v2? [ProtoMember(1, AsReference=true, DynamicType=true)] List<object> list; Thanks 回答1: At current, no and no - but I should; collections are a gap here currently. One I shall address soon. 来源: https://stackoverflow.com/questions/7012313/does-protobuf-net-support-object-graphs-of-shared-references-inside-list-arrays

How to embed type information for de-/serialization purposes using protobuf-net?

*爱你&永不变心* 提交于 2019-12-07 14:52:44
问题 I'd like to be able to serialize concrete instances of IMessage in such a way that the type information is retained/embedded (akin to what's available in e.g. Json.NET), so that upon deserialization that type information can be used to materialize those concrete instances. I'm well aware that the de-/serialization methods below don't work. Any guidance would be appreciated on how to change them so they do work. public interface IMessage {} public interface IEvent : IMessage {} [ProtoContract]

How to generate struct with ProtoGen from proto file

試著忘記壹切 提交于 2019-12-07 14:20:14
问题 We've been using protobuf-net ProtoGen to generate C# .cs file from *.proto file. We would like instead of class to generate struct. e.g. [DataContract] public struct Entity1 { [ProtoMember(1)] public double Field1 { get; set; } [ProtoMember(2)] public string Field2 { get; set; } } I tried to extract protocol buffer using method Serializer.GetProto for class and struct type. It seems, that protocol buffer (.proto) doesn't recognize difference between the struct and class. So I imply, that

Protobuf-net: How to serialize complex collection?

北慕城南 提交于 2019-12-07 14:07:37
问题 I'm trying to serialize this type of object using protobuf-net: [ProtoContract] public class RedisDataObject { [ProtoMember(1)] public string DataHash; [ProtoMember(2, DynamicType = true)] public Dictionary<ContextActions, List<Tuple<string, List<object>>>> Value; } [Serializable] public enum ContextActions { Insert, Update, Delete } I'm using List<object> because I'm storing there different class instances of other classes I have in my code. But I'm getting this error message: Unable to

How do you configure protobuf-net's RuntimeModel.Default to support serializing/deserializing a SessionSecurityToken?

前提是你 提交于 2019-12-07 12:41:56
问题 BinaryFormatter is able to handle serialization simply: private byte[] TokenToBytes(SessionSecurityToken token) { if (token == null) { return null; } using (var memoryStream = new MemoryStream()) { var binaryFormatter = new BinaryFormatter(); binaryFormatter.Serialize(memoryStream, token); return memoryStream.ToArray(); } } When I tried replacing BinaryFormatter with protobuf-net: using (var memoryStream = new MemoryStream()) { Serializer.Serialize(memoryStream, token); return memoryStream

Protobuf-net memcache provider null type error on deserialize

痞子三分冷 提交于 2019-12-07 12:16:22
问题 I'm using lastest protobuf-net lib with protobuf-net memcache provider. I need to serialize list of custom type MyClass [ProtoContract] public class MyClass{ [ProtoMember(1)] public int a {get; set;} [ProtoMember(2)] public int b {get; set;} } So I need to store/retreive: List<MyClass> myList When values are stored through protobuf and then retreived from cache all goes well. But if value is stored in memcache (in correct protobuf format) i.e. from another thread/app and after that that value

protobuf-net [de]serializing across assembly boundaries

 ̄綄美尐妖づ 提交于 2019-12-07 11:22:30
问题 I have a base class in one assembly and a large number of generated classes in another that inherit from the base class. Using protobuf-net (r282) to serialize a list of the base type fails when attempting to resolve the subclassType (line 248 of SerializerT.cs) because the subclass is not in the assembly of the base class. Moving the classes together is not a preferred option and it is rather important that I can pass around List. Here is my tagged base class. The included types are marked

protobuf-net's [ProtoInclude(1, “MyClass”)] did not work

那年仲夏 提交于 2019-12-07 11:04:03
问题 I am using protobuf-net v2 beta r431 for C# .net 4.0 application. In my application I have a Dictionary<int, IMyClass> which i need to serialize. A class MyClass implements IMyClass interface. As per protobuf's documentations I wrote the code as under: [ProtoContract] [ProtoInclude(1, typeof(MyClass))] public interface IMyClass { int GetId(); string GetName(); } [ProtoContract] [Serializable] public class MyClass : IMyClass { [ProtoMember(1)] private int m_id = 0; [ProtoMember(2)] private

Problems Deserializing Nested Dynamic Types with ProtoBuf-Net

丶灬走出姿态 提交于 2019-12-07 09:10:08
问题 I am trying to deserialize an object that is wrapped in several layers of DynamicType = true, using ProtoBuf-Net r668. Using an older version of ProtoBuf-Net (v1), it will deserialize without a problem. With the latest version, however, it fails with ProtoBuf.ProtoException : Internal error; a key mismatch occurred [ProtoContract] private class A { [ProtoMember(1, DynamicType = true)] public object Body { get; set; } } [ProtoContract] private class B { [ProtoMember(1, DynamicType = true)]

Protobuf-net : Nested IEnumerable objects

谁都会走 提交于 2019-12-07 01:47:02
问题 I am using Protobuf-net to serialize a custom nested list. I understand that native lists cannot be nested directly, which is why I have used a container object for the inner list. However, I would also like to make my container objects IEnumerable but this means Protobuf-net throws it out with the error: Nested or jagged lists and arrays are not supported Here is an example of my list structure which causes the error: [ProtoContract] public class MyOuterList<T> { [ProtoMember(1)] readonly