エンドポイント コンバーターを実装する

Version:
日本語翻訳に関する免責事項

このページの翻訳はAIによって自動的に行われました。可能な限り正確な翻訳を心掛けていますが、原文と異なる表現や解釈が含まれる場合があります。正確で公式な情報については、必ず英語の原文をご参照ください。

コンポーネントを表すSitecoreアイテムを実際のコンポーネントに変換するには、コンバーターが必要です。この例では、コンバーターはエンドポイント項目の設定をエンドポイント設定プラグインに変換します。その後、そのプラグインをエンドポイントに追加できます。

エンドポイントコンバータを実装するには:

  1. 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から継承することで、Sitecoreアイテムのフィールドからの値の読み取りを容易にするさまざまな方法にアクセスできます。

  2. プロジェクトをコンパイルします。

  3. Examples.DataExchange.Providers.FileSystem.dllをSitecoreサーバーにデプロイします。

この記事を改善するための提案がある場合は、 お知らせください!