Esempio n. 1
0
        public override async Task VersionedAsync(VersionContentContext 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 buildingPart = (ContentPart)context.BuildingContentItem.Get(activator.Type, partName);
                var existingPart = (ContentPart)context.ContentItem.Get(activator.Type, typePartDefinition.Name);

                if (buildingPart != null && existingPart != null)
                {
                    var partHandlers = _contentPartHandlerResolver.GetHandlers(partName);
                    await partHandlers.InvokeAsync((handler, context, existingPart, buildingPart) => handler.VersionedAsync(context, existingPart, buildingPart), context, existingPart, buildingPart, _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, existingPart, buildingPart) => handler.VersionedAsync(context, existingPart, buildingPart), context, existingPart, buildingPart, _logger);
                }
            }
        }
 async Task IContentPartHandler.VersionedAsync(VersionContentContext context, ContentPart existing, ContentPart building)
 {
     if (existing is TPart && building is TPart)
     {
         await VersionedAsync(context, (TPart)existing, (TPart)building);
     }
 }
Esempio n. 3
0
 void IContentPartHandler.Versioned(VersionContentContext context, ContentPart existing, ContentPart building)
 {
     if (existing is TPart && building is TPart)
     {
         Versioned(context, (TPart)existing, (TPart)building);
     }
 }
Esempio n. 4
0
        public override void Versioning(VersionContentContext context)
        {
            var utcNow = _clock.UtcNow;

            context.BuildingContentItem.CreatedUtc   = context.ContentItem.CreatedUtc ?? utcNow;
            context.BuildingContentItem.PublishedUtc = context.ContentItem.PublishedUtc;
            context.BuildingContentItem.ModifiedUtc  = utcNow;
        }
Esempio n. 5
0
        public override Task VersioningAsync(VersionContentContext context)
        {
            var utcNow = _clock.UtcNow;

            context.BuildingContentItem.Owner        = context.ContentItem.Owner;
            context.BuildingContentItem.CreatedUtc   = context.ContentItem.CreatedUtc ?? utcNow;
            context.BuildingContentItem.PublishedUtc = context.ContentItem.PublishedUtc;
            context.BuildingContentItem.ModifiedUtc  = utcNow;

            return(Task.CompletedTask);
        }
Esempio n. 6
0
        public override async Task VersionedAsync(VersionContentContext 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 buildingPart = (ContentPart)context.BuildingContentItem.Get(activator.Type, partName);
                var existingPart = (ContentPart)context.ContentItem.Get(activator.Type, typePartDefinition.Name);

                if (buildingPart != null && existingPart != null)
                {
                    await _partHandlers.InvokeAsync((handler, context, existingPart, buildingPart) => handler.VersionedAsync(context, existingPart, buildingPart), context, existingPart, buildingPart, Logger);
                }
            }
        }
 public virtual Task VersionedAsync(VersionContentContext context, TPart existing, TPart building) => Task.CompletedTask;
Esempio n. 8
0
 public virtual void Versioned(VersionContentContext context, TPart existing, TPart building)
 {
 }
Esempio n. 9
0
 public virtual Task VersionedAsync(VersionContentContext context)
 {
     return(Task.CompletedTask);
 }
Esempio n. 10
0
 Task IContentPartHandler.VersionedAsync(VersionContentContext context, ContentPart existing, ContentPart building)
 {
     return(existing is TPart texisting && building is TPart tbuilding
         ? VersionedAsync(context, texisting, tbuilding)
         : Task.CompletedTask);
 }