だからこれは私にとって新しいものです。
WinForms アプリの App.Config から取得するクラス ライブラリで ConfigurationSection クラスを定義しようとしています。これまでにこれを行ったことはありませんが、次の例から、これは私がしなければならないところです。
私のWinFormsアプリのapp.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="ReportEngineConfig" type="Optima.ReportEngine.ReportEngineConfig" allowDefinition="Everywhere" allowLocation="true"/>
</configSections>
<ReportEngineConfig>
<ReportObjectVariableRegEx value="test" ></ReportObjectVariableRegEx>
</ReportEngineConfig>
</configuration>
そして、別のクラス ライブラリのConfigurationSectionクラス。
System.Configuration を使用します。
namespace Optima.ReportEngine
{
public class ReportEngineConfig : ConfigurationSection
{
[ConfigurationProperty("ReportObjectVariableRegEx")]
public string ReportObjectVariableRegEx
{
get
{
return (string)this["value"];
}
}
}
}
だから、誰かが私が間違っているところを指摘できるチャンスがあれば
ありがとう!