コード例 #1
0
        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);
                }
            }
        }
コード例 #2
0
 void IContentPartHandler.Initialized(InitializingContentContext context, ContentPart part)
 {
     if (part is TPart)
     {
         Initialized(context, (TPart)part);
     }
 }
コード例 #3
0
 async Task IContentPartHandler.InitializedAsync(InitializingContentContext context, ContentPart part)
 {
     if (part is TPart)
     {
         await InitializedAsync(context, (TPart)part);
     }
 }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
 public virtual Task InitializedAsync(InitializingContentContext context, TPart instance) => Task.CompletedTask;
コード例 #6
0
 public virtual void Initialized(InitializingContentContext context, TPart instance)
 {
 }
コード例 #7
0
 public virtual Task InitializedAsync(InitializingContentContext context)
 {
     return(Task.CompletedTask);
 }
コード例 #8
0
 Task IContentPartHandler.InitializedAsync(InitializingContentContext context, ContentPart part)
 {
     return(part is TPart tpart
         ? InitializedAsync(context, tpart)
         : Task.CompletedTask);
 }