public override async Task VersionedAsync(VersionContentContext context) { var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(context.ContentItem.ContentType); if (contentTypeDefinition == null) { return; } foreach (var typePartDefinition in contentTypeDefinition.Parts) { var partName = typePartDefinition.PartDefinition.Name; var activator = _contentPartFactory.GetTypeActivator(partName); var buildingPart = (ContentPart)context.BuildingContentItem.Get(activator.Type, partName); var existingPart = (ContentPart)context.ContentItem.Get(activator.Type, typePartDefinition.Name); if (buildingPart != null && existingPart != null) { var partHandlers = _contentPartHandlerResolver.GetHandlers(partName); await partHandlers.InvokeAsync((handler, context, existingPart, buildingPart) => handler.VersionedAsync(context, existingPart, buildingPart), context, existingPart, buildingPart, _logger); // TODO: This can be removed in a future release as the recommended way is to use ContentOptions. // Iterate existing handler registrations as multiple handlers maybe not be registered with ContentOptions. await _partHandlers.InvokeAsync((handler, context, existingPart, buildingPart) => handler.VersionedAsync(context, existingPart, buildingPart), context, existingPart, buildingPart, _logger); } } }
async Task IContentPartHandler.VersionedAsync(VersionContentContext context, ContentPart existing, ContentPart building) { if (existing is TPart && building is TPart) { await VersionedAsync(context, (TPart)existing, (TPart)building); } }
void IContentPartHandler.Versioned(VersionContentContext context, ContentPart existing, ContentPart building) { if (existing is TPart && building is TPart) { Versioned(context, (TPart)existing, (TPart)building); } }
public override void Versioning(VersionContentContext context) { var utcNow = _clock.UtcNow; context.BuildingContentItem.CreatedUtc = context.ContentItem.CreatedUtc ?? utcNow; context.BuildingContentItem.PublishedUtc = context.ContentItem.PublishedUtc; context.BuildingContentItem.ModifiedUtc = utcNow; }
public override Task VersioningAsync(VersionContentContext context) { var utcNow = _clock.UtcNow; context.BuildingContentItem.Owner = context.ContentItem.Owner; context.BuildingContentItem.CreatedUtc = context.ContentItem.CreatedUtc ?? utcNow; context.BuildingContentItem.PublishedUtc = context.ContentItem.PublishedUtc; context.BuildingContentItem.ModifiedUtc = utcNow; return(Task.CompletedTask); }
public override async Task VersionedAsync(VersionContentContext context) { var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(context.ContentItem.ContentType); if (contentTypeDefinition == null) { return; } foreach (var typePartDefinition in contentTypeDefinition.Parts) { var partName = typePartDefinition.PartDefinition.Name; var activator = _contentPartFactory.GetTypeActivator(partName); var buildingPart = (ContentPart)context.BuildingContentItem.Get(activator.Type, partName); var existingPart = (ContentPart)context.ContentItem.Get(activator.Type, typePartDefinition.Name); if (buildingPart != null && existingPart != null) { await _partHandlers.InvokeAsync((handler, context, existingPart, buildingPart) => handler.VersionedAsync(context, existingPart, buildingPart), context, existingPart, buildingPart, Logger); } } }
public virtual Task VersionedAsync(VersionContentContext context, TPart existing, TPart building) => Task.CompletedTask;
public virtual void Versioned(VersionContentContext context, TPart existing, TPart building) { }
public virtual Task VersionedAsync(VersionContentContext context) { return(Task.CompletedTask); }
Task IContentPartHandler.VersionedAsync(VersionContentContext context, ContentPart existing, ContentPart building) { return(existing is TPart texisting && building is TPart tbuilding ? VersionedAsync(context, texisting, tbuilding) : Task.CompletedTask); }