public override async Task InitializedAsync(InitializingContentContext 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.InitializedAsync(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.InitializedAsync(context, part), context, part, _logger); } } }
void IContentPartHandler.Initialized(InitializingContentContext context, ContentPart part) { if (part is TPart) { Initialized(context, (TPart)part); } }
async Task IContentPartHandler.InitializedAsync(InitializingContentContext context, ContentPart part) { if (part is TPart) { await InitializedAsync(context, (TPart)part); } }
public override async Task InitializingAsync(InitializingContentContext 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; await _partHandlers.InvokeAsync((handler, context, part) => handler.InitializingAsync(context, part), context, part, Logger); } }
public virtual Task InitializedAsync(InitializingContentContext context, TPart instance) => Task.CompletedTask;
public virtual void Initialized(InitializingContentContext context, TPart instance) { }
public virtual Task InitializedAsync(InitializingContentContext context) { return(Task.CompletedTask); }
Task IContentPartHandler.InitializedAsync(InitializingContentContext context, ContentPart part) { return(part is TPart tpart ? InitializedAsync(context, tpart) : Task.CompletedTask); }