1: Namespace Einstein.Core.Security.Config
2:
3: <System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1052:StaticHolderTypesShouldBeSealed")> Public Class Settings
4: Private Sub New()
5: End Sub
6: Public Shared Sub ProtectSection(ByVal sectionName As String, ByVal provider As String)
7: Dim config As System.Configuration.Configuration = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(HttpContext.Current.Request.ApplicationPath())
8: Dim section As ConfigurationSection = config.GetSection(sectionName)
9: If Not (section Is Nothing) AndAlso Not section.SectionInformation.IsProtected Then
10: section.SectionInformation.ProtectSection(provider)
11: config.Save()
12: End If
13: End Sub
14:
15:
16: Public Shared Sub UNProtectSection(ByVal sectionName As String)
17: Dim config As System.Configuration.Configuration = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(HttpContext.Current.Request.ApplicationPath())
18: Dim section As ConfigurationSection = config.GetSection(sectionName)
19: If Not (section Is Nothing) AndAlso section.SectionInformation.IsProtected Then
20: section.SectionInformation.UnprotectSection()
21: config.Save()
22: End If
23: End Sub
24: End Class
25: End Namespace