Implement a value accessor converter
Current version: 4.0
You must create a converter that can convert the settings on a value accessor item into a plugin. You can then specify the converter on the value accessor template in order to identify an endpoint for pipeline steps to read from.
To create the converter:
-
In Visual Studio, add the following class:
RequestResponsec#using Sitecore.DataExchange.Attributes; using Sitecore.DataExchange.Converters.DataAccess.ValueAccessors; using Sitecore.DataExchange.DataAccess; using Sitecore.DataExchange.DataAccess.Readers; using Sitecore.DataExchange.DataAccess.Writers; 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(ArrayValueAccessorTemplateId)] public class ArrayValueAccessorConverter : ValueAccessorConverter { public const string ArrayValueAccessorTemplateId = "[ARRAY VALUE ACCESSOR TEMPLATE ID]"; public const string TemplateFieldPosition = "Position"; public ArrayValueAccessorConverter(IItemModelRepository repository) : base(repository) { } protected override IValueReader GetValueReader(ItemModel source) { var reader = base.GetValueReader(source); if (reader == null) { var position = this.GetIntValue(source, TemplateFieldPosition); if (position < 0) { return null; } reader = new ArrayValueReader(position); } return reader; } protected override IValueWriter GetValueWriter(ItemModel source) { var writer = base.GetValueWriter(source); if (writer == null) { var position = this.GetIntValue(source, TemplateFieldPosition); if (position < 0) { return null; } writer = new ArrayValueWriter(position); } return writer; } } }
ImportantYou must change the value of
[ARRAY VALUE ACCESSOR TEMPLATE ID]
to match the ID from the value accessor template named Array Value Accessor that you created in the previous step. -
Compile the project.
-
Deploy
Examples.DataExchange.Providers.FileSystem.dll
to the Sitecore server.