protobuf-net

How to map System Enum's in Protobuf.Net

£可爱£侵袭症+ 提交于 2019-12-12 13:20:53
问题 I have a class which has a property of type System.IO.FileAttribute (enum) Upon serializing with protobuf-net I get the error: No wire-value is mapped to the enum System.IO.FileAttributes.Hidden, System, Archive How would I go about mapping system enum's to a Contract with Members? 回答1: That is a [Flags] enum, which doesn't really have a direct map in protobuf (as defined by google). I would simply re-expose as int : public FileAttributes Attributes {get;set;} [ProtoMember(12)] // whavever

protobuf-net : how to represent DateTime in C#?

蓝咒 提交于 2019-12-12 12:24:50
问题 protogen.exe generates this pattern for a proto2 message field of type long : private long _Count = default(long); [global::ProtoBuf.ProtoMember(1, IsRequired = false, Name=@"Count", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] [global::System.ComponentModel.DefaultValue(default(long))] public long Count { get { return _Count; } set { _Count = value; } } but as proto2 does not include a date-time type ( and protobuf-net does not support proto3 which includes google.protobuf

No serializer defined for type: System.Management.Automation.PSObject in Protobuf-net

∥☆過路亽.° 提交于 2019-12-12 11:35:01
问题 this is my class [ProtoContract] internal class Powershellresults { internal Powershellresults() { } [ProtoMember(1)] public Collection<PSObject> PsObjects { get; set; } [ProtoMember(2)] public string Script { get; set; } [ProtoMember(3)] public string Viewname { get; set; } } but i get No serializer defined for type: System.Management.Automation.PSObject when i try to serialize it private byte[] SerializeResults(Powershellresults obj) { byte[] data; using (var ms = new MemoryStream()) {

Protobuf.net GetProto<Type>() method throws a not implemented exception

爷,独闯天下 提交于 2019-12-12 09:46:32
问题 I have a .net application that serializes using protobuf, and I wanted to create a python client that can communicate with it. Since my object graph is quite complex (and I am lazy busy) I wanted to quickly generate the .proto files directly from the C# classes like this: string proto = Serializer.GetProto<YourType>(); Unfortunately this method is throwing a not implemented exception for me :'( I am using the Dec 11 version Has this feature been dropped? Is there a newer version I should be

Reference integrity in BinaryFormatter

99封情书 提交于 2019-12-12 09:36:58
问题 The existence of AsReference option in Protobuf-net and the word that BinaryFormatter is a "graph serializer" lead me to assume that BinaryFormatter does not maintain references and that it makes a copy of every object. But I did some tests and found out that all references in a single BinaryFormatter Serialize() or Deserialize() call are maintained even for recursive referencing. Can I confirm that BinaryFormatter does indeed maintain references? How is this different from Protobuf-net?

C# .net protocol buffers - protobuf-net support for serializing dictionary of object values?

跟風遠走 提交于 2019-12-12 09:36:38
问题 i'm new to protocol buffers and I am using protobuf-net for VS2010. from what i'm reading here Dictionary in protocol buffers, it doesn't seem that protobuf can serialize a dictionary with object types as values. but here on his site i read this: Notes on types supported: custom classes that: are marked as data-contract have a parameterless constructor for Silverlight: are public many common primitives etc single dimension arrays: T[] List / IList Dictionary / IDictionary any type which

DataContract serialization with protobuf-net r275

你离开我真会死。 提交于 2019-12-12 09:27:46
问题 I just updated to r275 version and it doesn't seem to manage correctly DataContract classes any more By serializing this very simple class: [DataContract] public class ProtoData { [DataMember(Order = 1)] private long _id; [DataMember(Order = 2)] private string _firstName; [DataMember(Order = 3)] private string _lastName; public long Id { get { return _id; } set { _id = value; } } public string FirstName { get { return _firstName; } set { _firstName = value; } } public string LastName { get {

Protobuf-net Deserialize Open Street Maps

与世无争的帅哥 提交于 2019-12-12 08:49:28
问题 For the life of me I cannot deserialize the protobuf file from Open Street Maps. I am trying to deserialize the following extract: http://download.geofabrik.de/osm/north-america/us-northeast.osm.pbf to get Nodes and I am using http://code.google.com/p/protobuf-net/ as the library. I have tried to deserialize a bunch of different objects but they all come up null. The proto files can be found here: http://trac.openstreetmap.org/browser/applications/utils/export/osm2pgsql/protobuf Any

Protocol buffer serializing with inheritance. Derived classes are empty

≯℡__Kan透↙ 提交于 2019-12-12 05:42:13
问题 I faced with strange problem. After reading a lot, I tried to deploy protobuf-net in my app. Classes binds with simple inheritance. After presumably successful serialization, I am trying to deserialize to list, but protobuf filling only base class! here a bit of code: serializing function private static void serialize<T>(T obj) where T: Log { using (var fileStream = new FileStream(fileName, FileMode.Append)) { Serializer.SerializeWithLengthPrefix(fileStream, obj, PrefixStyle.Base128,

nuget - Reference specific framework version from installed package?

空扰寡人 提交于 2019-12-12 05:12:20
问题 This scenario goes a bit against the whole way nuget works so what i might be asking for is a hack... My problem: I need to have Restsharp and Protobuf-net referred to in a .net assembly that going into SQL-CLR for Server 2008 (so max .net 3.5, framework 2.0). Restsharp goes back to 3.5 as the lowest supported fwk version. Protobuf-net 3.5 onwards has a lot of gunk referring to system.servicemodel (and WCF) which i don't need and use and actively want to remove because it causes issues with