Ejemplo n.º 1
0
 public BuildPartIndexContext(
     DocumentIndex documentIndex,
     ContentItem contentItem,
     string key,
     ContentTypePartDefinition typePartDefinition,
     ContentIndexSettings settings)
     : base(documentIndex, contentItem, key)
 {
     ContentTypePartDefinition = typePartDefinition;
     Settings = settings;
 }
Ejemplo n.º 2
0
 public BuildFieldIndexContext(
     DocumentIndex documentIndex,
     ContentItem contentItem,
     IList <string> keys,
     ContentPart contentPart,
     ContentTypePartDefinition typePartDefinition,
     ContentPartFieldDefinition partFieldDefinition,
     ContentIndexSettings settings)
     : base(documentIndex, contentItem, keys, typePartDefinition, settings)
 {
     ContentPartFieldDefinition = partFieldDefinition;
     ContentPart = contentPart;
 }
        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);
        }
        Task IContentPartIndexHandler.BuildIndexAsync(ContentPart contentPart, ContentTypePartDefinition typePartDefinition, BuildIndexContext context, ContentIndexSettings settings)
        {
            var part = contentPart as TPart;

            if (part == null)
            {
                return(Task.CompletedTask);
            }

            var buildPartIndexContext = new BuildPartIndexContext(context.DocumentIndex, context.ContentItem, typePartDefinition.Name, typePartDefinition, settings);

            return(BuildIndexAsync(part, buildPartIndexContext));
        }
        Task IContentPartIndexHandler.BuildIndexAsync(ContentPart contentPart, ContentTypePartDefinition typePartDefinition, BuildIndexContext context, ContentIndexSettings settings)
        {
            var part = contentPart as TPart;

            if (part == null)
            {
                return(Task.CompletedTask);
            }

            var keys = new List <string>();

            keys.Add(typePartDefinition.Name);
            foreach (var key in context.Keys)
            {
                keys.Add($"{key}.{typePartDefinition.Name}");
            }

            var buildPartIndexContext = new BuildPartIndexContext(context.DocumentIndex, context.ContentItem, keys, typePartDefinition, settings);

            return(BuildIndexAsync(part, buildPartIndexContext));
        }
Ejemplo n.º 6
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;
        }