Skip to content

Instantly share code, notes, and snippets.

@martinrayenglish
Created August 22, 2020 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinrayenglish/a30f58b4423b48a4237e90c024f122c0 to your computer and use it in GitHub Desktop.
Save martinrayenglish/a30f58b4423b48a4237e90c024f122c0 to your computer and use it in GitHub Desktop.
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Sitecore.Framework.Conditions;
using Sitecore.Xdb.Collection.Indexing;
using Sitecore.Xdb.Collection.Model;
namespace Test.SCExtensions.Xdb.Collection.Search.Solr
{
internal sealed class IndexWriterFilterDecorator : IIndexWriter
{
private readonly IIndexWriter _writer;
public IndexWriterFilterDecorator(IIndexWriter writer)
{
this._writer = Condition.Requires<IIndexWriter>(writer, nameof (writer)).IsNotNull<IIndexWriter>().Value;
}
public async Task<Task> Write(ChangedDataRecords changes, CancellationToken cancellationToken)
{
changes = Condition.Requires<ChangedDataRecords>(changes, nameof (changes)).IsNotNull<ChangedDataRecords>().Value;
ChangedDataRecords filteredChanges = new ChangedDataRecords(changes.get_ContactRecords(), (IReadOnlyCollection<InteractionDataRecord>) new List<InteractionDataRecord>().AsReadOnly(), changes.get_DeletedContactIds(), changes.get_DeletedInteractionIds());
Task task = await this._writer.Write(filteredChanges, cancellationToken).ConfigureAwait(false);
return task;
}
public async Task SignalChangesHaveBeenWritten(byte[] token, CancellationToken cancellationToken)
{
await this._writer.SignalChangesHaveBeenWritten(token, cancellationToken).ConfigureAwait(false);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment