设置文件为序列化字典

编程入门 行业动态 更新时间:2024-10-11 11:13:07
本文介绍了设置文件为序列化字典的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这是一个三部分问题。

一个使用

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.

更多推荐

设置文件为序列化字典

本文发布于:2023-11-22 04:51:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1616040.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字典   文件   序列化

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!