对于场景是protobuf网不是合适? [英] For which scenarios is protobuf-net not appropriate?
问题描述
我们一直在使用BinarySerialization与我们的C#应用程序,但大小和需要的类的复杂性进行连载中sloooooow(德)序列化和大型文件的结果。
We have been using BinarySerialization with our C# app, but the size and complexity of the classes which need to be serialized results in sloooooow (de)serialization, and large files.
我们怀疑,我们应该写我们自己的定制序列;但protobuf网索赔显著速率和标准.NET二进制序列化规模优势,并且可以更容易地加入到我们的应用程序比大量定制序列化。
We suspect that we should just write our own custom serializers; but protobuf-net claims significant speed and size advantages over standard .Net binary serialization, and may be easier to add to our app than a large number of bespoke serializers.
花显著的时间和精力,试图让它为我们工作之前,我很想知道是否有任何交易断路器。我们使用的接口定义的属性,抽象子类,定制位标记枚举,泛型列表等等等等等什么会阻止protobuf网为我们工作?
Before spending significant time and effort trying to get it to work for us, I would love to know whether there are any deal-breakers. We are using properties defined with interfaces, generic lists of abstract sub-classes, custom bit flag enums, etc etc etc. What would stop protobuf-net working for us?
推荐答案
protobuf网做的事情能坚持核心protobuf的规范,然后是一些(例如,它包括继承),但是:
protobuf-net does what it can to adhere to the core protobuf spec, and then some (for example, it includes inheritance), however:
- V1是不是很擅长基于接口的性质(即
ICustomer
等);我努力让这V2改进 - V1喜欢那里是一个参数的构造函数(这要求在解除第2版)
- 您需要告诉它如何将模型映射到领域;在V1这需要的类型的装饰(或有是的从名称等推断出一些事情的一个选项);在V2这个也可以放在外部
- 在V1,标志枚举是一种痛苦;在V2有到直通枚举为原料整数选项,使其成为falgs
- 摘要和继承是很好,但您必须更加适合能够提前确定的时间所有的具体类型(映射他们整数键)
- 仿制药应罚款
- 交错数组/嵌套列表没有的中间类型都不行 - 你可以在中间
- 并非所有的核心类型有内置的支持(新的日期/时间偏置类型,例如);在V2如果有必要 您可以介绍一下你自己的垫片这种
- 这是一个树串行器,而不是一个图串;我有一些想法那里,但没有任何尚未实施
- v1 is not very good at interface-based properties (i.e.
ICustomer
etc); I'm working on getting this improved in v2 - v1 likes there to be a parameterless constructor (this requirement is lifted in v2)
- you need to tell it how to map the model to fields; in v1 this needs to be decorated on the type (or there is an option to infer some things from the names etc); in v2 this can be done externally
- in v1, flags enums are a pain; in v2 there is an option to pass-thru enums as raw integers, making it much more suitable for falgs
- abstracts and inheritance are fine, but you must be able to determine all the concrete types ahead of time (to map them to integer keys)
- generics should be fine
- jagged arrays / nested lists without intermediate types aren't OK - you can shim this by introducing an intermediate type in the middle
- not all core types have inbuilt support (the new date/time offset types, for example); in "v2" you can introduce your own shims for this if necessary
- it is a tree serializer, not a graph serializer; I have some thoughts there, but nothing implemented yet
如果有你想要什么序列化一些有限的例子中,我会高兴地看看,看看它是否是可能的工作(我的作者)。
If there is some limited example of what you want to serialize, I'll happily take a look to see if it is likely to work (I'm the author).
这篇关于对于场景是protobuf网不是合适?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!