Settings File as Dictionary with Serialization

自闭症网瘾萝莉.ら 提交于 2019-12-11 11:51:10

问题


This is a three part question.

One: Would using a

Dictionary<String,Object>

be a good way of saving data where it would be

Dictionary<Key,Value>

as the basis?

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 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.

Rolling my own class using Dictionary as the basis made sense if I could serialize it into a file.


回答1:


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.



来源:https://stackoverflow.com/questions/2891658/settings-file-as-dictionary-with-serialization

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!