自定义类型应用程序设置和序列化

编程入门 行业动态 更新时间:2024-10-27 09:38:54
本文介绍了自定义类型应用程序设置和序列化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

晚安, 希望你们中的一些优秀专家可以帮助我,我有一个应用程序,我需要在应用程序设置中保存设置,这是但是我需要将它们暴露在构建中的settings / config文件中。 正常设置没有问题但是对于每个设置我需要它有3个值,这是'DDERow','DDECol'和'DDELength'。将有大约12种不同的设置,我不想有12 * 3的设置。 i一直在寻找在应用程序设置中添加自定义类型但是很难得到这个通过向属性添加自定义类型来实现。

导入 System.Configuration < SettingsSerializeAs(Configuration.SettingsSerializeAs.Xml)> _ 公开 类 DDESetting ' BackBones 私有 _SettingDDERow 正如 整数 私有 _SettingDDECol 正如 整数 私有 _SettingDDELength 正如 整数 Sub 新() 结束 Sub 公开 属性 DDERow 作为 整数 获取 返回 _SettingDDERow 结束 获取 设置(值正如 整数) _SettingDDERow = value 结束 设置 结束 属性 公共 属性 DDECol As 整数 获取 返回 _SettingDDECol 结束 获取 设置( value As Integer ) _SettingDDECol = value 结束 设置 结束 属性 公共 属性 DDELength 作为 整数 获取 返回 _SettingDDELength 结束 获取 设置(值作为 整数) _SettingDDELength = value 结束 设置 结束 属性 结束 Class

i现在可以在我的主应用程序中选择它作为设置,但它只显示一个文本框放入一个值,我怎么能得到它所以我可以在设置页面上添加所有3个设置,然后在配置文件中序列化。 预期输出: < ; settingname > < DDERow > < DDECol > < DDELength > < / settingname >

和我希望能够通过普通的 My.Settings 命名空间访问它,所以:

My.Settings.SettingName.DDERow My.Settings.SettingName.DDECol My.Settings.SettingName.DDELength

[/编辑] 感谢您提供的任何帮助。 我我正在使用VS2010

解决方案

这是使用SettingsProvider

解决的

Good Evening, Hope some of you fine experts can assist me on this, i have an application that i need to save the settings in application settings which is fine however i need them to be exposed in the settings/config file on build. No issues with normal settings however for each setting i need it to have 3 values, which are 'DDERow','DDECol' and 'DDELength'. there will be about 12 different settings and i dont want to have 12 * 3 settings. i have been looking at adding custom types to the application settings but struggling to get this achieved by adding a custom type to the property.

Imports System.Configuration <SettingsSerializeAs(Configuration.SettingsSerializeAs.Xml)> _ Public Class DDESetting 'BackBones Private _SettingDDERow As Integer Private _SettingDDECol As Integer Private _SettingDDELength As Integer Sub New() End Sub Public Property DDERow As Integer Get Return _SettingDDERow End Get Set(value As Integer) _SettingDDERow = value End Set End Property Public Property DDECol As Integer Get Return _SettingDDECol End Get Set(value As Integer) _SettingDDECol = value End Set End Property Public Property DDELength As Integer Get Return _SettingDDELength End Get Set(value As Integer) _SettingDDELength = value End Set End Property End Class

i can now select this in my main application as a setting but it only shows a textbox to put a single value you in, how can i get it so i can add all 3 settings in on the settings page and then serialise it in the config file. [EDIT] Expected output:

< settingname> <DDERow> <DDECol> <DDELength> </settingname>

and i want to be able to access it via the normal My.Settings namespace so:

My.Settings.SettingName.DDERow My.Settings.SettingName.DDECol My.Settings.SettingName.DDELength

[/EDIT] Appreciate any help you can give. I am using VS2010

解决方案

This was resolved using SettingsProvider

更多推荐

自定义类型应用程序设置和序列化

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

发布评论

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

>www.elefans.com

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