DoconutOptions
Doconut サービスの構成
DoconutOptions(名前空間 Doconut)は SDK 全体の単一構成オブジェクトです。AddDoconut() 内で一度だけ構成し、シングルトンとして登録されます。
builder.Services.AddDoconut(options =>
{
options.LicensePath = "Doconut.Viewer.lic";
options.UnsafeMode = false;
options.ShowDoconutInfo = false;
options.AddPlugin<Doconut.Plugins.Dicom.DicomPlugin>();
});プロパティ
| 型 | プロパティ | デフォルト | 説明 |
|---|---|---|---|
bool | ShowDoconutInfo | false | true の場合、トークンなしのミドルウェア要求は 404 の代わりにバージョンバナー(Doconut <version> is running on <host>)を返します。スモークチェックに便利です。運用時は false のままにしてください。 |
bool | UnsafeMode | false | true の場合、ページ要求時の ASP.NET セッション セキュリティチェックをスキップします。運用時は false のままにしてください(Core Concepts → Sessions & Security を参照)。 |
string | MiddlewarePath | "/doconut" | ページ画像エンドポイントの調整値です。検証は行われますが、パイプラインのブランチはマウントされません。実際の UseDoconut() マッピングおよびクライアントの BasePath と合わせてください。 |
string | ResourcesPath | "/doconut-res" | 埋め込み JS/CSS/画像/フォントリソースの URL パスプレフィックスです。 |
string | LicensePath | "" | ライセンス ファイルへのパスです。空の場合は次のライセンス ソースへ、さらに自動検出へと進みます。何も見つからない場合は、機能が制限された透かし付き評価状態になります。 |
string | LicenseContent | "" | 生の XML ライセンス コンテンツ(データベース、環境変数、シークレットマネージャー)。LicensePath より優先されます。 |
Stream? | LicenseStream | null | ストリームとしてのライセンスで、起動時に一度読み取られます。他の両方のソースよりも優先されます。 |
bool | ResetLicense | false | 互換性のために予約されたフラグです。現在の .NET 8 実装では使用されません。ライセンスを置き換えた後、アプリケーションを再起動してください。 |
DoconutPluginRegistry | PluginRegistry | — | プラグインの貢献を収集する読み取り専用レジストリで、ビューア ファクトリによって使用されます。AddPlugin<T>() で設定します。 |
ライセンスの優先順位(サービス登録時に適用): LicenseStream → LicenseContent → LicensePath → 自動検出(Getting Started → License Setup を参照)。
メソッド
AddPlugin()
DoconutOptions AddPlugin<TPlugin>() where TPlugin : IDoconutPlugin, new()このメソッドは、リリースされたオプトインの Converter および DICOM パッケージに使用します。Annotation と通常の Search は組み込みのライセンス機能であり、AddPlugin<TPlugin>() は使用しません。
ファーストパーティ プラグイン(Converter、DICOM)を登録します。フルエントにオプション インスタンスを返します。AddDoconut() は、ライセンスが欠如している、レガシーな TRIAL ファイルがある、またはプラグインの機能を許可しない有料ライセンスの場合に InvalidOperationException をスローします。一時的/デモの登録は有効期限が切れても保持され、ランタイムゲートの対象となります(Core Concepts → Plugin System を参照)。
オプトインの Converter ウィジェットは AddConverterWidget() で有効化され、読み取り専用の ConverterWidget プロパティを通じて提供されます。そのオプションは Converter Plugin ページ(Plugins → Converter Plugin)に記載されています。
RegisterViewer(extension, factory, defaultConfig?)
DoconutOptions RegisterViewer(
string extension, // ".myext" — leading dot optional
Func<IFormatViewer> factory,
Func<BaseConfig>? defaultConfig = null)ファイル拡張子に対して カスタムビューア を登録します。カスタムビューアは組み込みおよびプラグインのビューアよりも優先され、ライセンス制限を受けません。defaultConfig が省略され、ドキュメントが明示的な設定なしで開かれた場合は ImageConfig が使用されます。
空の拡張子の場合は ArgumentException(Extension must be a non-empty file extension.)を、null のファクトリの場合は ArgumentNullException をスローします。
起動時の検証
AddDoconut() はオプションを 早期失敗 で検証するため、設定ミスはリクエスト時の混乱する 404 ではなく、起動時に明確な例外として表れます。
DoconutOptions.MiddlewarePath must be a non-empty path starting with '/'.
DoconutOptions.ResourcesPath must be a non-empty path starting with '/'.
DoconutOptions.MiddlewarePath and ResourcesPath must be different paths.一般的な構成
// Production: explicit license, everything locked down (all security defaults)
builder.Services.AddDoconut(options =>
{
options.LicenseContent = builder.Configuration["Doconut:License"] ?? "";
});
// Custom paths (e.g. to avoid a route conflict)
builder.Services.AddDoconut(options =>
{
options.MiddlewarePath = "/docs-engine";
options.ResourcesPath = "/docs-assets";
});ResourcesPath を変更した場合は、クライアントウィジェットの ResPath を同期させてください(ViewerConfig を参照)。
MiddlewarePath は自動的な ASP.NET Core ルートマッパーではありません。Doconut がカスタムプレフィックス以下でのみ応答すべき場合は、そのブランチに UseDoconut() をマウントしてください(例: app.Map("/docs-engine", branch => branch.UseDoconut()))。そしてクライアントの BasePath を同じ URL に設定します。
このページは役に立ちましたか?