registrysettingsprovider.vb

来自「讲解visual studio的应用」· VB 代码 · 共 59 行

VB
59
字号
Imports System.Configuration

Public Class WebServiceSettingsProvider
    Inherits SettingsProvider

    Private _appName As String = "Settings"
    Public Overrides Property ApplicationName() As String
        Get
            Return Me._appName
        End Get
        Set(ByVal value As String)
            Me._appName = value
        End Set
    End Property


    Public Overrides Sub Initialize(ByVal name As String, ByVal config As System.Collections.Specialized.NameValueCollection)
        MyBase.Initialize(Me.ApplicationName, config)
    End Sub



    ''' <summary>
    ''' Get the settings for this application 
    ''' </summary>
    Public Overrides Function GetPropertyValues( _
                                  ByVal context As SettingsContext, _
                                  ByVal collection As SettingsPropertyCollection) _
                                        As SettingsPropertyValueCollection
        Dim values As New SettingsPropertyValueCollection
        For Each settingProperty As SettingsProperty In collection
            Dim settingValue As New SettingsPropertyValue(settingProperty)
            settingValue.IsDirty = False

            settingValue.SerializedValue = _
                     My.WebServices.Settings.GetPropertyValue(settingProperty.Name)
            values.Add(settingValue)
        Next
        Return values
    End Function

    ''' <summary>
    ''' Update the settings that have changed.  
    ''' </summary>
    Public Overrides Sub SetPropertyValues( _
                             ByVal context As SettingsContext, _
                             ByVal collection As SettingsPropertyValueCollection)
        For Each propertyValue As SettingsPropertyValue In collection
            My.WebServices.Settings.SetPropertyValue( _
                                        propertyValue.Name, _
                                        propertyValue.SerializedValue)
        Next
    End Sub




End Class

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?