public ContentQueryService( IAppProvider appProvider, IAssetUrlGenerator assetUrlGenerator, IContentRepository contentRepository, IContentVersionLoader contentVersionLoader, IScriptEngine scriptEngine, IOptions <ContentOptions> options, EdmModelBuilder modelBuilder) { Guard.NotNull(appProvider, nameof(appProvider)); Guard.NotNull(assetUrlGenerator, nameof(assetUrlGenerator)); Guard.NotNull(contentRepository, nameof(contentRepository)); Guard.NotNull(contentVersionLoader, nameof(contentVersionLoader)); Guard.NotNull(modelBuilder, nameof(modelBuilder)); Guard.NotNull(options, nameof(options)); Guard.NotNull(scriptEngine, nameof(scriptEngine)); this.appProvider = appProvider; this.assetUrlGenerator = assetUrlGenerator; this.contentRepository = contentRepository; this.contentVersionLoader = contentVersionLoader; this.modelBuilder = modelBuilder; this.options = options.Value; this.scriptEngine = scriptEngine; }
public ContentQueryService( IAppProvider appProvider, IAssetUrlGenerator assetUrlGenerator, IContentEnricher contentEnricher, IContentRepository contentRepository, IContentLoader contentVersionLoader, IScriptEngine scriptEngine, ContentQueryParser queryParser) { Guard.NotNull(appProvider); Guard.NotNull(assetUrlGenerator); Guard.NotNull(contentEnricher); Guard.NotNull(contentRepository); Guard.NotNull(contentVersionLoader); Guard.NotNull(queryParser); Guard.NotNull(scriptEngine); this.appProvider = appProvider; this.assetUrlGenerator = assetUrlGenerator; this.contentEnricher = contentEnricher; this.contentRepository = contentRepository; this.contentVersionLoader = contentVersionLoader; this.queryParser = queryParser; this.scriptEngine = scriptEngine; this.queryParser = queryParser; }
public ConvertData(IAssetUrlGenerator assetUrlGenerator, IAssetRepository assetRepository, IContentRepository contentRepository) { Guard.NotNull(assetUrlGenerator); Guard.NotNull(assetRepository); Guard.NotNull(contentRepository); this.assetUrlGenerator = assetUrlGenerator; this.assetRepository = assetRepository; this.contentRepository = contentRepository; }
public ResolveAssets(IAssetUrlGenerator assetUrlGenerator, IAssetQueryService assetQuery, IRequestCache requestCache) { Guard.NotNull(assetUrlGenerator); Guard.NotNull(assetQuery); Guard.NotNull(requestCache); this.assetUrlGenerator = assetUrlGenerator; this.assetQuery = assetQuery; this.requestCache = requestCache; }
public ContentEnricher(IAssetQueryService assetQuery, IAssetUrlGenerator assetUrlGenerator, Lazy <IContentQueryService> contentQuery, IContentWorkflow contentWorkflow) { Guard.NotNull(assetQuery); Guard.NotNull(assetUrlGenerator); Guard.NotNull(contentQuery); Guard.NotNull(contentWorkflow); this.assetQuery = assetQuery; this.assetUrlGenerator = assetUrlGenerator; this.contentQuery = contentQuery; this.contentWorkflow = contentWorkflow; }
public static FieldConverter ResolveAssetUrls(IReadOnlyCollection <string>?fields, IAssetUrlGenerator urlGenerator) { if (fields?.Any() != true) { return((data, field) => data); } var isAll = fields.First() == "*"; return((data, field) => { if (field is IField <AssetsFieldProperties> && (isAll || fields.Contains(field.Name))) { foreach (var partition in data) { if (partition.Value is JsonArray array) { for (var i = 0; i < array.Count; i++) { var id = array[i].ToString(); array[i] = JsonValue.Create(urlGenerator.GenerateUrl(id)); } } } } return data; }); }
public static FieldConverter ResolveAssetUrls(IReadOnlyCollection <string>?fields, IAssetUrlGenerator urlGenerator) { if (fields?.Any() != true) { return((data, field) => data); } bool ShouldHandle(IField field, IField?parent = null) { if (field is IField <AssetsFieldProperties> ) { if (fields.Contains("*")) { return(true); } if (parent == null) { return(fields.Contains(field.Name)); } else { return(fields.Contains($"{parent.Name}.{field.Name}")); } } return(false); } void Resolve(IJsonValue value) { if (value is JsonArray array) { for (var i = 0; i < array.Count; i++) { var id = array[i].ToString(); array[i] = JsonValue.Create(urlGenerator.GenerateUrl(id)); } } } return((data, field) => { if (ShouldHandle(field)) { foreach (var partition in data) { Resolve(partition.Value); } } else if (field is IArrayField arrayField) { foreach (var partition in data) { if (partition.Value is JsonArray array) { for (var i = 0; i < array.Count; i++) { if (array[i] is JsonObject arrayItem) { foreach (var(key, value) in arrayItem) { if (arrayField.FieldsByName.TryGetValue(key, out var nestedField) && ShouldHandle(nestedField, field)) { Resolve(value); } } } } } } } return data; }); }