Esempio n. 1
0
        public override async Task DraftSavedAsync(SaveDraftContentContext 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.DraftSavedAsync(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.DraftSavedAsync(context, part), context, part, _logger);
                }
            }
        }
        public override async Task DraftSavedAsync(SaveDraftContentContext 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.DraftSavedAsync(context, part), context, part, _logger);
                }
            }
        }
Esempio n. 3
0
 public virtual Task DraftSavedAsync(SaveDraftContentContext context, TPart instance) => Task.CompletedTask;
Esempio n. 4
0
 Task IContentPartHandler.DraftSavedAsync(SaveDraftContentContext context, ContentPart part)
 {
     return(part is TPart tpart
         ? DraftSavedAsync(context, tpart)
         : Task.CompletedTask);
 }
 public virtual Task DraftSavingAsync(SaveDraftContentContext context)
 {
     return(Task.CompletedTask);
 }