エンドポイントコンバータを実装する
このページの翻訳はAIによって自動的に行われました。可能な限り正確な翻訳を心掛けていますが、原文と異なる表現や解釈が含まれる場合があります。正確で公式な情報については、必ず英語の原文をご参照ください。
コンポーネントを表すSitecoreアイテムを実際のコンポーネントに変換するにはコンバーターが必要です。この例では、コンバーターがエンドポイントアイテムの設定をエンドポイント設定プラグインに変換します。そのプラグインをエンドポイントに追加できます。
エンドポイントコンバータを実装するには:
-
Visual Studioで、次のクラスを追加します:
using Sitecore.DataExchange.Attributes; using Sitecore.DataExchange.Converters.Endpoints; using Sitecore.DataExchange.Models; using Sitecore.DataExchange.Repositories; using Sitecore.Services.Core.Model; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;
namespace Examples.DataExchange.Providers.FileSystem { SupportedIds(TextFileEndpointTemplateId) public class TextFileEndpointConverter : BaseEndpointConverter { public const string TextFileEndpointTemplateId = "ENDPOINT TEMPLATE ID"; public const string TemplateFieldColumnSeparator = "ColumnSeparator"; public const string TemplateFieldColumnHeadersInFirstLine = "ColumnHeadersInFirstLine"; public const string TemplateFieldPath = "Path"; public TextFileEndpointConverter(IItemModelRepository repository) : base(repository) { } protected override void AddPlugins(ItemModel source, Endpoint endpoint) { // //create the plugin var settings = new TextFileSettings { // //populate the plugin using values from the item ColumnHeadersInFirstLine = this.GetBoolValue(source, TemplateFieldColumnHeadersInFirstLine), ColumnSeparator = this.GetStringValue(source, TemplateFieldColumnSeparator), Path = this.GetStringValue(source, TemplateFieldPath) }; // //add the plugin to the endpoint endpoint.AddPlugin(settings); } } }
!重要ENDPOINT TEMPLATE IDの値を、Text File Endpointという名前のエンドポイントテンプレートのIDに合わせて変更しなければなりません。
!注BaseEndpointConverter(base-endpoint-converter.html "Base endpoint converter") から継承することで、Sitecore項目のフィールドから値を読み取るのを容易にする多くの手法にアクセスできます。
-
プロジェクトをコンパイルします。
-
Examples.DataExchange.Providers.FileSystem.dllをSitecoreサーバーにデプロイしてください。