具有自定义字典的XML序列化的IEqualityComparer [英] XML serialization of a Dictionary with a custom IEqualityComparer
问题描述
我要序列具有自定义的IEqualityComparer字典。
I want to serialize a Dictionary that has a custom IEqualityComparer.
我一直使用的DataContractSerializer尝试,但我不能让比较器进行序列化。
I've tried using DataContractSerializer but I can't get the Comparer to be serialized.
我不能使用,因为的这个
我总是可以这样做:
var myDictionary = new MyDictionary(deserializedDictionary, myComparer);
但是,这意味着我需要两倍的字典使用的内存。
But that means I'd need twice the memory the dictionary uses.
推荐答案
我刚才读错误报告...
I just read the error report...
二进制对象
图形序列化失败,超过〜1320万
的对象。
Binary serialization fails for object graphs with more than ~13.2 million objects.
如果你有一个图,大,你总是会遇到一些问题。
if you have a graph that big, you always may have some problems.
你想尝试另一种串行? protobuf网是继谷歌的协议缓冲区格式,并且可以为工作组较大,尤其是在组模式定制的二进制序列。
Would you like to try an alternative serializer? "protobuf-net" is a bespoke binary serializer following Google's protocol buffers format, and may work for larger sets, especially in "group" mode.
这篇关于具有自定义字典的XML序列化的IEqualityComparer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!