对于 Silverlight 应用程序中的数据存储来说,什么是一个好的、简单的解决方案?

发布于 2024-12-10 07:59:48 字数 356 浏览 0 评论 0原文

我有一个在 IIS 上运行的 silverlight 应用程序,当前有一些数据列表硬编码到 c# 中,我知道这不是一个好主意,但这是为了概念验证演示,现在我需要继续从另一个源获取数据可以修改。

我查看了 xml 文件以及 sql 数据库。问题是客户端不愿意允许在机器上安装任何额外的东西(漫长的安全过程),因此 sql express 可能不实用。我也尝试过研究 sql 紧凑版,但我似乎无法找到任何关于它的像样的教程。

数据由三个相当短的小对象列表组成,其中包含字符串和整数。我正在寻找一种最好是简单且快速实施的解决方案,理想情况下不需要在服务器上安装任何额外内容。

有人有任何可能有用的建议或链接吗?

提前致谢

I have a silverlight application running on an IIS which currently has some data lists hard coded into the c#, not a good idea I know but this was for a proof of concept demo and now I need to move on to getting the data from another source which can be modified.

I've looked at xml files as well as an sql database. The problem is that the client is reluctant to allow anything extra to be installed on the machine (long security process) and so sql express may not be practical. I've also tried to look into sql compact edition but I cannot seem to be able to find any decent tutorials about it.

The data is made up of three, fairly short, lists of small objects which contain strings and integers. I'm looking for a, preferably, simple and quick to implement solution which ideally does not need anything extra installing on the server.

Does anyone have any suggestions or links which may be handy?

Thanks in advance

Cap

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

雨的味道风的声音 2024-12-17 07:59:48

如果您习惯使用 LINQ 而不是 SQL 来查询数据,Sterling DB 听起来非常适合您。它非常轻量级,并且不需要服务器或客户端上的任何额外内容(显然除了将其包含在代码中之外)。它使用隔离存储来存储数据。所有序列化/反序列化都由库为您处理。

编辑:

根据您关于数据是“静态”的评论(意味着所有客户端都使用相同的数据),最好不要使用像 Sterling 这样的客户端数据库,甚至(正如您提到的)SQL CE。您对硬编码此类“目录”数据持保留态度是正确的,因为该数据的更改将需要新版本的软件。

进行抽象的一种简单方法是在包含所有数据的 XAP 旁边托管一个 XML 文件。您可以按照您想要的任何方式编写 XML。在软件中,下载 XML 文件、解析它并在每次应用程序运行时填充目录应该相当简单。当需要更改目录时,只需修改 XML 文件即可。

If you are comfortable using LINQ to query your data instead of SQL, Sterling DB sounds perfect for you. It's extremely lightweight, and requires nothing extra on the server or the client (other than including it in your code obviously). It uses isolated storage to store data. All of the serialization/deserialization is taken care of for you by the library.

Edit:

Based on your comment that the data is "static" (meaning all clients consume the same data), it's probably best not to use a client-side database like Sterling or even (as you mentioned) SQL CE. You are right to have reservations about hard-coding this type of "catalog" data, as changes in that data would require a new release of software.

A simple way to make the abstraction is to simply host an XML file alongside your XAP that contains all your data. You can author the XML in any way you want. In the software, it should be fairly straightforward to download the XML file, parse it, and populate your catalog each time the app runs. When changes to the catalog are necessary, it's just a matter of modifying the XML file.

够钟 2024-12-17 07:59:48

我知道这不是一个理想的解决方案,但您可以尝试使用制表符分隔的文本文件。它们是最容易创建的。

I know this is not an ideal solution but you could try using tab separated text files. They are the easiest to create.

网名女生简单气质 2024-12-17 07:59:48

我使用 XML (web.config) 来存储所有客户端使用的数据,例如预配置或默认用户设置值,并使用 隔离存储,用于与客户端无关的数据,例如用户 UI 布局设置。

I use XML (web.config) to store data use by all clients such as pre-configure or default user setting value and use Isolated Storage for client-independent data, such as, user UI-layout setting.

哭了丶谁疼 2024-12-17 07:59:48

我会将对象序列化为 XML 并将它们存储在服务器上,这相对容易做到

你可以将值拉入 XDocument

XDocument ConnectionStrings = XDocument.Load(System.AppDomain.CurrentDomain.BaseDirectory + "ConnectionStrings.xml");

这是我正在使用的序列化函数

    private static XDocument Serialize<T>(object obj)
    {
        XDocument ReturnValue = new XDocument();

        //Create our Serializer with the type that was passed in
        XmlSerializer Serializer = new XmlSerializer(typeof(T));

        //Serialize our object to a string writer
        System.IO.StringWriter sw = new System.IO.StringWriter();        
        Serializer.Serialize(sw, obj);

        //We use a string reader to read the string from our Writer (created when serialized)
        System.IO.StringReader sr; 
        sr = new System.IO.StringReader(sw.ToString());

        //Then we can load the string reader giving us an XDocument
        ReturnValue = XDocument.Load(sr);

        return ReturnValue;
    }
    private static T Deserialize<T>(XDocument Xdoc)
    {
        T ReturnValue;

        //Create our Serializer with the type that was passed in
        XmlSerializer Serializer = new XmlSerializer(typeof(T));

        //Create a string reader to access the XML data in our XDocument
        System.IO.StringReader sr = new System.IO.StringReader(Xdoc.ToString());

        //Deserialize the XML into our object
        ReturnValue = (T)Serializer.Deserialize(sr);

        return ReturnValue;
    }

I would serialize the objects to XML and store them on the server, it's relatively easy to do

You can pull the values into and XDocument

XDocument ConnectionStrings = XDocument.Load(System.AppDomain.CurrentDomain.BaseDirectory + "ConnectionStrings.xml");

Here are the serialization function i'm using

    private static XDocument Serialize<T>(object obj)
    {
        XDocument ReturnValue = new XDocument();

        //Create our Serializer with the type that was passed in
        XmlSerializer Serializer = new XmlSerializer(typeof(T));

        //Serialize our object to a string writer
        System.IO.StringWriter sw = new System.IO.StringWriter();        
        Serializer.Serialize(sw, obj);

        //We use a string reader to read the string from our Writer (created when serialized)
        System.IO.StringReader sr; 
        sr = new System.IO.StringReader(sw.ToString());

        //Then we can load the string reader giving us an XDocument
        ReturnValue = XDocument.Load(sr);

        return ReturnValue;
    }
    private static T Deserialize<T>(XDocument Xdoc)
    {
        T ReturnValue;

        //Create our Serializer with the type that was passed in
        XmlSerializer Serializer = new XmlSerializer(typeof(T));

        //Create a string reader to access the XML data in our XDocument
        System.IO.StringReader sr = new System.IO.StringReader(Xdoc.ToString());

        //Deserialize the XML into our object
        ReturnValue = (T)Serializer.Deserialize(sr);

        return ReturnValue;
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文