111,092
社区成员




<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<!-- 自定义节 -->
<sectionGroup name="DataTypeGroup">
<section name ="DataTypeSection" type = "AppConfiguration.DataTypeSection, AppConfiguration"/>
</sectionGroup>
</configSections>
<DataTypeGroup>
<DataTypeSection>
<!--
<node key="SqlDataType_00" type="char" SqlSqlDbType="c"></node>
-->
<SqlNodes name="SqlDataType">
<add key="SqlDataType_00" type="char" SqlDbType="Char"/>
<add key="SqlDataType_01" type="nchar" SqlDbType="NChar"/>
<add key="SqlDataType_02" type="varchar" SqlDbType="VarChar"/>
<add key="SqlDataType_03" type="nvarchar" SqlDbType="NVarChar"/>
<add key="SqlDataType_04" type="text" SqlDbType="Text"/>
<add key="SqlDataType_05" type="ntext" SqlDbType="NText"/>
<add key="SqlDataType_06" type="bit" SqlDbType="Bit"/>
<add key="SqlDataType_07" type="binary" SqlDbType="Binary"/>
<add key="SqlDataType_08" type="tinyint" SqlDbType="TinyInt"/>
<add key="SqlDataType_09" type="smallint" SqlDbType="SmallInt"/>
<add key="SqlDataType_10" type="int" SqlDbType="Int"/>
<add key="SqlDataType_11" type="bigint" SqlDbType="BigInt"/>
<add key="SqlDataType_12" type="float" SqlDbType="Float"/>
<add key="SqlDataType_13" type="real" SqlDbType="Real"/>
<add key="SqlDataType_14" type="number" SqlDbType="Decimal"/>
<add key="SqlDataType_15" type="smallmoney" SqlDbType="SmallMoney"/>
<add key="SqlDataType_16" type="money" SqlDbType="Money"/>
<add key="SqlDataType_17" type="smalldatetime" SqlDbType="SmallDateTime"/>
<add key="SqlDataType_18" type="datetime" SqlDbType="DateTime"/>
<add key="SqlDataType_19" type="image" SqlDbType="Image"/>
</SqlNodes>
<OleNodes name="AccessDataType">
<add key="AccessDBDataType_00" type="Text" OleDbType="VarWChar"/>
<add key="AccessDBDataType_01" type="Memo" OleDbType="LongVarWChar"/>
<add key="AccessDBDataType_02" type="Byte" OleDbType="UnsignedTinyInt"/>
<add key="AccessDBDataType_03" type="Boolean" OleDbType="Boolean"/>
<add key="AccessDBDataType_04" type="Date/Time" OleDbType="Date"/>
<add key="AccessDBDataType_05" type="Currency" OleDbType="Numeric"/>
<add key="AccessDBDataType_06" type="Short" OleDbType="SmallInt"/>
<add key="AccessDBDataType_07" type="Long" OleDbType="Integer"/>
<add key="AccessDBDataType_08" type="Single" OleDbType="Single"/>
<add key="AccessDBDataType_09" type="Double" OleDbType="Double"/>
<add key="AccessDBDataType_10" type="Binary" OleDbType="Binary"/>
<add key="AccessDBDataType_11" type="OLE Object" OleDbType="LongVarBinary"/>
</OleNodes>
</DataTypeSection>
</DataTypeGroup>
</configuration>
public static void Protect(string sectionName)
{
try
{
string provider = "RsaProtectedConfigurationProvider";
string path = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
ConfigurationSection section = config.GetSection(sectionName);
if (null != section && !section.SectionInformation.IsProtected)
{
section.SectionInformation.ProtectSection(provider);
section.SectionInformation.ForceSave = true;
config.Save(ConfigurationSaveMode.Full);
ConfigurationManager.RefreshSection(sectionName);
}
}
catch (Exception ex)
{
throw ex;
}
}