Esempio n. 1
0
        public override async Task CloningAsync(CloneContentContext 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 part      = context.ContentItem.Get(activator.Type, typePartDefinition.Name) as ContentPart;

                if (part != null)
                {
                    var partHandlers = _contentPartHandlerResolver.GetHandlers(partName);
                    await partHandlers.InvokeAsync((handler, context, part) => handler.CloningAsync(context, part), context, part, _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, part) => handler.CloningAsync(context, part), context, part, _logger);
                }
            }
        }
Esempio n. 2
0
 async Task IContentPartHandler.ClonedAsync(CloneContentContext context, ContentPart part)
 {
     if (part is TPart tpart)
     {
         await ClonedAsync(context, tpart);
     }
 }
Esempio n. 3
0
        public override async Task CloningAsync(CloneContentContext 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 part      = context.ContentItem.Get(activator.Type, typePartDefinition.Name) as ContentPart;

                if (part != null)
                {
                    await _partHandlers.InvokeAsync((handler, context, part) => handler.CloningAsync(context, part), context, part, Logger);
                }
            }
        }
 public virtual Task CloningAsync(CloneContentContext context)
 {
     return(Task.CompletedTask);
 }
Esempio n. 5
0
 public virtual Task ClonedAsync(CloneContentContext context, TPart part) => Task.CompletedTask;