protobuf-net

OnDeserialized attribute for ProtoBuf-NET

谁都会走 提交于 2019-12-10 23:26:29
问题 We used JSON.NET to serialize our data together with OnDeserialized attribute to execute custom code after deserialization: [OnDeserialized] internal void OnDeserializedMethod(StreamingContext context) { ... } Now we try to use protobuf instead of JSON.NET and this method is not executing. Is there another way to achieve this behaviour with protobuf.net ? Here is an example that doesn't work: class Program { static void Main(string[] args) { RuntimeTypeModel.Default.Add(typeof (Profile),

protobuf-net: Cannot serialize type data, How can I define type data with protocol buffers?

蓝咒 提交于 2019-12-10 23:08:08
问题 I am trying to create a simple in-memory grid that can be serialized using protocol buffers. The idea is the user can create/define columns of any type (primitives or user defined as long as they're protocol buffers tagged). My problem is you can't serialize Type data with protocol buffers so how can i achieve this? Code is below showing how i'd hoped to code the Columns of the grid. Thanks a lot. [TestClass] public class UnitTest1 { [TestMethod] public void TestMethod1() { Column colOrderId

Cross-Platform Protobuf Serialization

本秂侑毒 提交于 2019-12-10 22:38:38
问题 I have three applications that are communicating via ZeroMQ all performing different operations. The different applications are as follows: The first is a C++ application which is an engine for "hard work", this takes a Protobuf message as a request from a client, does some work, and returns a Protobuf message back to that client (or whoever is connected, Request/Reply Pattern). This uses 0MQ version 4.0.4 and using protobuf-2.6.0 where we have built the required header files ourselves, the

Differentiation between empty lists and null lists cannot be worked around using Surrogates in protobuf-net [closed]

纵饮孤独 提交于 2019-12-10 22:33:41
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 8 years ago . protobuf does not have built-in support of differentation between empty lists and null lists. However, our business objects do differ because null means

Protobuf-net WCF response is empty

烂漫一生 提交于 2019-12-10 22:27:39
问题 I have a WCF Contract outlining a test method that just returns an instance of a class across WCF using protobuf-net. I can serialize and deserialize in a test application but when I make the request via WCF the response the class instance exists, but all its properties are null. Here are the relevant config files and class definitions: [ProtoContract] public class TestClass { [ProtoMember(1)] public int TestInt { get; set; } [ProtoMember(2)] public string TestString { get; set; } } ...

exception while serializing a graph

懵懂的女人 提交于 2019-12-10 20:11:53
问题 I'm still playing with the newly released version of protobuf-net and I'm facing an issue I don't understand. let's consider the piece of code below: [ProtoContract] class Node { public Node() { Children = new List<Node>(); } [ProtoMember(1, IsRequired = true)] public int Data { get; set; } [ProtoMember(2, IsRequired = true, AsReference = true)] public List<Node> Children { get; set; } public void AddChild(Node child) { Children.Add(child); } } static void Main() { Node n = new Node {Data = 0

Is it possible to serialize/deserialize immutable types with protobuf-net on Windows Phone 7/8?

让人想犯罪 __ 提交于 2019-12-10 20:00:00
问题 Is it possible to serialize/deserialize types with protobuf-net on Windows Phone 7/8? I've tried the code below, it seems Constructor skipping isn't supported (i.e. UseConstructor = false) so I created a parameterless constructor but the deserialization fails with "Attempt to access the method failed: Wp7Tests.ImmutablePoint.set_X(System.Double)" public class ImmutablePoint { public double X { get; private set; } public double Y { get; private set; } public ImmutablePoint() {} public

Communication between processes using WCF and F#

孤街浪徒 提交于 2019-12-10 19:59:22
问题 I would like to make a simple one to one communication between two long time running F# processes using F#. They will exchange information regularly every ca. 5 seconds. Until now, I have reached this point: #r "System.ServiceModel" #r "System.Runtime.Serialization" //#r @"d:\DLL\Protobuf\protobuf-net.dll" #time "on" open System.ServiceModel [<ServiceContract>] type IService = [<OperationContract>] // [<ProtoBuf.ServiceModel.ProtoBehavior>] abstract Test: float [] [] [] -> string type Service

InvalidOperationException when serializing [Flags] enum with protobuf-net

二次信任 提交于 2019-12-10 19:30:43
问题 I am trying to serialize an enum type that is decorated with [Flags] attribute. The enum declaration is as follows: [Flags] [ProtoContract(EnumPassthru = true)] public enum Categories { [ProtoEnum(Name = nameof(Invalid), Value = 0x0)] Invalid = 0x0, [ProtoEnum(Name = nameof(A), Value = 0x1)] A = 0x1, [ProtoEnum(Name = nameof(B), Value = 0x2)] B = 0x2, [ProtoEnum(Name = nameof(C), Value = 0x4)] C = 0x4, [ProtoEnum(Name = nameof(D), Value = 0x8)] D = 0x8, [ProtoEnum(Name = nameof(Global), Value

DefaultValue properties deserialization

谁说胖子不能爱 提交于 2019-12-10 18:37:43
问题 I'm trying to deserialize stream to object with default value properties and protobuf-net just ingores this properties when they are missing in the stream. Do i need to manually set before deserialization all properties to their default values or that? 回答1: The DefaultValues behavior (not just in protobuf-net - in System.ComponentModel generally , for example PropertyGrid , PropertyDescriptor , etc) is that this is used to indicate things that don't need to be serialized, because they will be