Skip to content

Instantly share code, notes, and snippets.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<contentSearch>
<!-- Configuration sections for indexes -->
<indexConfigurations>
<!-- If an index has no configuration specified, it will use the configuration below. The configuration is not merged if the index also has
configuration, it is either this configuration or the index configuration. -->
<customSolrIndexConfiguration type="Sitecore.ContentSearch.SolrProvider.SolrIndexConfiguration, Sitecore.ContentSearch.SolrProvider">
<!-- This flag will index all fields by default. This allows new fields in your templates to automatically be included into the index.
public class XMLSystemSettings : Sitecore.DataExchange.IPlugin
{
public XMLSystemSettings()
{
}
public string XMLNodeName { get; set; }
public string XMLPath { get; set; }
}
public static class EndpointExtensions
{
//This extension method makes it easier to access the plugin when it is needed.
//Providing extension methods to access a plugin is a best practice to consider when implementing a provider for Data Exchange Framework.
public static XMLSystemSettings GetXMLSystemSettings(this Endpoint endpoint)
{
return endpoint.GetPlugin<XMLSystemSettings>();
}
public class XMLSystemEndpointItemModel : ItemModel
{
public const string XMLNodeName = "XMLNodeName";
public const string XMLPath = "XMLPath";
}
public class XMLSystemEndpointConverter : BaseEndpointConverter<ItemModel>
{
//the id from the endpoint template you created named XML Endpoint.
private static readonly Guid TemplateId = Guid.Parse("{CC05EF8C-F4C8-4EB9-A39A-8E71F978C1DD}");
public XMLSystemEndpointConverter(IItemModelRepository repository) : base(repository)
{
//identify the template an item must be based
//on in order for the converter to be able to
//convert the item
public class ReadXMLDataStepItemModel : ItemModel
{
public const string EndpointFrom = "EndpointFrom";
}
public class ReadXMLDataStepConverter : BasePipelineStepConverter<ItemModel>
{
// the id from the pipeline step template you created named Read XML Data Pipeline Step.
private static readonly Guid TemplateId = Guid.Parse("{00191A02-F1B4-406C-B3CB-60568CCDD6D3}");
public ReadXMLDataStepConverter(IItemModelRepository repository) : base(repository)
{
this.SupportedTemplateIds.Add(TemplateId);
}
protected override void AddPlugins(ItemModel source, PipelineStep pipelineStep)
{
[RequiredEndpointPlugins(typeof(XMLSystemSettings))]
public class ReadXMLDataStepProcessor : BaseReadDataStepProcessor
{
public ReadXMLDataStepProcessor()
{
}
protected override void ReadData(
Endpoint endpoint,
PipelineStep pipelineStep,
public class XMLElementValueAccessorItemModel
{
public const string ElementName = "ElementName";
}
public class XMLElementValueReader : IValueReader
{
public readonly string ElementName;
public XMLElementValueReader(string elementName)
{
this.ElementName = elementName;
}
public CanReadResult CanRead(object source, DataAccessContext context)