Repository navigation
OTR_ConfigParameter
nishi_74322014 edited this page Oct 27, 2026
·
1 revision
Open 棟梁での設定値(外部パラメタ)の置き場と、読み方。
- .NET Framework では
*.config(app.config/web.config)、.NET ではappsettings.jsonを使う。 - 読み出しは、
GetConfigParameterだけを使う。ConfigurationManagerやIConfigurationを直接使わない(ランタイムの差とコンテナ対応を吸収している)。
| 種類 | 置き場 | 取得 |
|---|---|---|
| 一般設定・接続文字列 |
appSettings / connectionStrings
|
GetConfigParameter.GetConfigValue / GetConnectionString
|
| アプリ共通の独自パラメタ(key-value) | 共有情報定義(SPDefinition.xml) |
GetSharedProperty.GetSharedPropertyValue |
| メッセージ |
MSGDefinition.xml / .resx
|
メッセージ定義 |
| 接続文字列と分離レベルの組み合わせ | TCDefinition.xml |
トランザクション制御 |
- XML の定義ファイル(
FxXML*Definition)は、ランタイムによらず XML のまま。
using Touryo.Infrastructure.Public.Util;
string path = GetConfigParameter.GetConfigValue("FxLog4NetConfFile");
string conn = GetConfigParameter.GetConnectionString("ConnectionString_SQL");| メソッド | 読む場所 | net48 | net10.0 |
|---|---|---|---|
GetConfigValue(key) |
appSettings |
○ | ○ |
GetConnectionString(key) |
connectionStrings |
○ | ○ |
GetAnyConfigValue(key) |
任意のキー(: 区切りで階層指定) |
✗ | ○ |
GetAnyConfigSection(key) |
任意のセクション | ✗ | ○ |
両方のランタイムに対応するコードでは、GetConfigValue / GetConnectionString だけを使う。
| net48 | net10.0 | |
|---|---|---|
| 構成ファイル |
app.config / web.config
|
appsettings.json |
| 初期化 | 不要 |
GetConfigParameter.InitConfiguration() が必須(.NET版の初期化処理) |
| 環境変数での上書き | — |
appSettings__キー名 などで上書きできる(Docker対応) |
- 設定値の中の
%変数%(%OT_RESOURCE_ROOT%など)は、Open 棟梁が環境変数で展開する(OS に依存しない)。
- 設定は起動時に読み、キャッシュする前提である。オンライン中の変更は反映されない。
- 変更は再起動(
web.configの変更では IIS がアプリケーション・プールを再起動する)、無停止ならローリング・アップグレードで運用する。
既定のコンストラクタを使ったシングルトンで独自の XML や DB テーブルを読み込み、key-value ストア(Dictionary など)に格納しておくと、性能面でもよい。
- スキル
opentouryo-configと、リポジトリのroot/programs/CONFIGURATION.mdを読ませる。 - 設定ファイルの「仕組み」の説明は
CONFIGURATION.mdに集約されている。エージェントに設定ファイルへ長い説明を書き足させない。
Tags: 再構築
このWikiは「Open棟梁Project」,「OSSコンソーシアム 開発基盤部会」によって運営されています。