Skip to content

Instantly share code, notes, and snippets.

@KevinJump
Created October 5, 2021 21:26
Show Gist options
  • Save KevinJump/a7fb152f6432b4f2f33492008d4b02ee to your computer and use it in GitHub Desktop.
Save KevinJump/a7fb152f6432b4f2f33492008d4b02ee to your computer and use it in GitHub Desktop.
Sample of how to replace the content serializer in uSync with something that doesn't serialize certain properties. (would need testing)
using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Services;
using uSync8.ContentEdition.Mapping;
using uSync8.Core;
using uSync8.Core.Serialization;
namespace uSync8.ContentEdition.Serializers
{
[ComposeAfter(typeof(uSync8.ContentEdition.uSyncContentComposer))]
public class CustomContentComposer : IUserComposer
{
public void Compose(Composition composition)
{
composition.Register<ISyncSerializer<IContent>, CustomContentPropertySerializer>();
}
}
[SyncSerializer("", "contentPropertySerializer", uSyncConstants.Serialization.Content)]
public class CustomContentPropertySerializer : ContentSerializer
{
public CustomContentPropertySerializer(IEntityService entityService, ILocalizationService localizationService, IRelationService relationService, ILogger logger, IContentService contentService, IFileService fileService, SyncValueMapperCollection syncMappers)
: base(entityService, localizationService, relationService, logger, contentService, fileService, syncMappers)
{
this.dontSerialize = new string[] { "myPayPalPropertyAlias" };
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment