这是一个三部分问题。
一个使用
Dictionary<String,Object>是保存数据的好方法
Dictionary<Key,Value>作为基础?
两个:如果没有使用app.settings或xml,那将是一个更好的方法?
Two: What would be a better way without using app.settings or xml?
三:你如何序列化这个(或更好的解决方案)成为紧凑的二进制格式并快速序列化?
Three: How would you serialize this(Or the better solution) into a binary format that is compact and serializes quickly?
Xml非常冗长,寻找二进制,因为它的大小。 另外,如果我使用Dictionary,这将很容易做一个设置类简单的
Xml is very verbose and I was looking for binary due to it's size. Also, if I used Dictionary, it would have been easy to make a settings class with simply
GetValue(Key) and SetValue(Key,Obj) or object.SetValue(Settings,Key) using extensions.我正在使我的应用程序打开插件,所以我想要一个统一的规范,所有应用程序使用的设置。
I am making my application open for plugins so I wanted a uniform spec for settings that all applications use.
如果我可以将其序列化到一个文件中,使用Dictionary作为基础滚动我自己的类。
Rolling my own class using Dictionary as the basis made sense if I could serialize it into a file.
推荐答案尝试使用 protobuf-net 。这将解决您的三个问题。我上周看了一下,并在短短几天内取代了我基于xml的整个消息传递基础架构。 Marc Gravell在这里是经常的贡献者,他对我的查询的回复非常及时和有帮助。
Try using protobuf-net. This would solve all three of your problems. I looked at it last week, and replaced my entire xml-based messaging infrastructure in just a couple of days. Marc Gravell is a frequent contributor on here, and he was very prompt and helpful in his replies to my queries.
更多推荐
设置文件为序列化字典
发布评论