エンドポイント設定プラグインを実装してください
このページの翻訳はAIによって自動的に行われました。可能な限り正確な翻訳を心掛けていますが、原文と異なる表現や解釈が含まれる場合があります。正確で公式な情報については、必ず英語の原文をご参照ください。
エンドポイントの設定はエンドポイントテンプレートを使って設定されます。この例では、読み取れるファイルのパスや、ファイルの最初の行に列ヘッダーがあるかどうかなどの設定が可能です。
エンドポイントテンプレートは、エンドポイント設定へのデザインタイムアクセスを提供します。エンドポイント設定への実行時アクセスはプラグインを通じて提供されます。エンドポイントの特定の設定を処理するにはプラグインを使用する必要があります。
エンドポイント設定プラグインを実装するには:
-
Visual Studioで、次のクラスを追加します:
using Sitecore.DataExchange; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;
namespace Examples.DataExchange.Providers.FileSystem { public class TextFileSettings : IPlugin { public TextFileSettings() { } public bool ColumnHeadersInFirstLine { get; set; } public string ColumnSeparator { get; set; } public string Path { get; set; } } }
-
次のクラスを加えます:
using Sitecore.DataExchange.Models; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;
namespace Examples.DataExchange.Providers.FileSystem { public static class EndpointExtensions { public static TextFileSettings GetTextFileSettings(this Endpoint endpoint) { return endpoint.GetPlugin
(); } public static bool HasTextFileSettings(this Endpoint endpoint) { return (GetTextFileSettings(endpoint) != null); } } }
!注この拡張メソッドは、必要なときにプラグインにアクセスしやすくします。
プラグインへのアクセスための拡張メソッドを提供することは、Data Exchange Frameworkのプロバイダーを実装する際に考慮すべきベストプラクティスです。