public override async Task CreatedAsync(CreateContentContext 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.CreatedAsync(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.CreatedAsync(context, part), context, part, _logger); } } }
void IContentPartHandler.Created(CreateContentContext context, ContentPart part) { if (part is TPart) { Created(context, (TPart)part); } }
async Task IContentPartHandler.CreatedAsync(CreateContentContext context, ContentPart part) { if (part is TPart) { await CreatedAsync(context, (TPart)part); } }
public override void Creating(CreateContentContext context) { var utcNow = _clock.UtcNow; if (!context.ContentItem.CreatedUtc.HasValue) { context.ContentItem.CreatedUtc = utcNow; } context.ContentItem.ModifiedUtc = utcNow; var httpContext = _httpContextAccessor.HttpContext; if (context.ContentItem.Owner == null && (httpContext?.User?.Identity?.IsAuthenticated ?? false)) { context.ContentItem.Owner = httpContext.User.Identity.Name; } }
public override Task CreatingAsync(CreateContentContext context) { var utcNow = _clock.UtcNow; if (!context.ContentItem.CreatedUtc.HasValue) { context.ContentItem.CreatedUtc = utcNow; } context.ContentItem.ModifiedUtc = utcNow; var httpContext = _httpContextAccessor.HttpContext; if (context.ContentItem.Owner == null && (httpContext?.User?.Identity?.IsAuthenticated ?? false)) { context.ContentItem.Owner = context.ContentItem.Author = httpContext.User.Identity.Name; } return(Task.CompletedTask); }
public override async Task CreatingAsync(CreateContentContext 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.CreatingAsync(context, part), context, part, Logger); } } }
public virtual Task CreatedAsync(CreateContentContext context, TPart instance) => Task.CompletedTask;
public virtual void Created(CreateContentContext context, TPart instance) { }
public virtual Task CreatedAsync(CreateContentContext context) { return(Task.CompletedTask); }
Task IContentPartHandler.CreatedAsync(CreateContentContext context, ContentPart part) { return(part is TPart tpart ? CreatedAsync(context, tpart) : Task.CompletedTask); }