Task IContentFieldIndexHandler.BuildIndexAsync(ContentPart contentPart, ContentTypePartDefinition typePartDefinition, ContentPartFieldDefinition partFieldDefinition, BuildIndexContext context, ContentIndexSettings settings)
        {
            if (!string.Equals(typeof(TField).Name, partFieldDefinition.FieldDefinition.Name) &&
                !string.Equals(nameof(ContentField), partFieldDefinition.FieldDefinition.Name))
            {
                return(Task.CompletedTask);
            }

            var field = contentPart.Get <TField>(partFieldDefinition.Name);

            if (field != null)
            {
                var keys = new List <string>();
                foreach (var key in context.Keys)
                {
                    keys.Add($"{key}.{partFieldDefinition.Name}");
                }
                keys.Add($"{typePartDefinition.Name}.{partFieldDefinition.Name}");

                var buildFieldIndexContext = new BuildFieldIndexContext(context.DocumentIndex, context.ContentItem, keys, contentPart, typePartDefinition, partFieldDefinition, settings);

                return(BuildIndexAsync(field, buildFieldIndexContext));
            }

            return(Task.CompletedTask);
        }
Exemple #2
0
        Task IContentFieldIndexHandler.BuildIndexAsync(ContentPart contentPart, ContentTypePartDefinition typePartDefinition, ContentPartFieldDefinition partFieldDefinition, BuildIndexContext context, ContentIndexSettings settings)
        {
            if (!string.Equals(typeof(TField).Name, partFieldDefinition.FieldDefinition.Name) &&
               !string.Equals(nameof(ContentField), partFieldDefinition.FieldDefinition.Name))
            {
                return Task.CompletedTask;
            }

            var field = contentPart.Get<TField>(partFieldDefinition.Name);
            if (field != null)
            {
                var buildFieldIndexContext = new BuildFieldIndexContext(context.DocumentIndex, context.ContentItem, $"{typePartDefinition.Name}.{partFieldDefinition.Name}", contentPart, typePartDefinition, partFieldDefinition, settings);

                return BuildIndexAsync(field, buildFieldIndexContext);
            }

            return Task.CompletedTask;
        }
 public abstract Task BuildIndexAsync(TField field, BuildFieldIndexContext context);