自定义类型应用程序设置和序列化 [英] Custom Type in Application Settings and Serialisation
问题描述
晚安,
希望你们中的一些优秀专家可以帮助我,我有一个应用程序,我需要在应用程序设置中保存设置,这是但是我需要将它们暴露在构建中的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
结束 获取
< span class =code-keyword>设置(值作为 整数)
_SettingDDELength = value
结束 设置
结束 属性
结束 Class
i现在可以在我的主应用程序中选择它作为设置,但它只显示一个文本框放入一个值,我怎么能得到它所以我可以在设置页面上添加所有3个设置,然后在配置文件中序列化。
预期输出:
<前lang =xml> < ; 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
这篇关于自定义类型应用程序设置和序列化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!