public ContentItemData TransformContentItemData(ContentItemData originalItem, ContentItemFields newValues, ContentType contentType) { contentType.Fields .ToList() .ForEach(x => SetField(originalItem, x.Id, GetFieldValue(originalItem, newValues, x))); return(originalItem); }
public ContentItem ConvertToContentItem(ContentItemData entry, ContentType contentType, PublishingTarget target) { return(new ContentItem { Fields = GetContentItemFields(entry, contentType), Info = GetContentItemInfo(entry, contentType, target), }); }
private ContentItemFields GetContentItemFields(ContentItemData entry, ContentType contentType) { var fields = new ContentItemFields(); contentType.Fields .ToList() .ForEach(x => fields.Add(x.Id, AdaptField(entry, x))); return(fields); }
private ContentItemInfo GetContentItemInfo(ContentItemData entry, ContentType contentType, PublishingTarget target) { return(new ContentItemInfo { Id = GetContentItemId(entry), Language = GetContentItemLanguage(entry), TemplateId = contentType.SystemProperties.Id, TemplateName = contentType.Name, PublishingTarget = target.ToString(), }); }
private void SetField(ContentItemData item, string fieldId, dynamic fieldValue) { if (!item.ContainsKey(fieldId)) { item.Add(fieldId, fieldValue); } else { item[fieldId] = fieldValue; } }
private ContentSearchResult ConvertToContentSearchResult(ContentItemData entry, ContentType contentType, PublishingTarget target) { using (_profiler.Measure(nameof(ConvertToContentSearchResult))) { return(new ContentSearchResult { Item = new ContentItemResult { Value = ConvertToContentItem(entry, contentType, target), }, }); } }
private ContentItem ConvertToContentItem(ContentItemData entry, ContentType contentType, PublishingTarget target) { return(_converter.ConvertToContentItem(entry, contentType, target)); }
private ContentItem ConvertToContentsSearchResultItem(ContentItemData entry, PublishingTarget publishingTarget) { var contentType = _query.GetContentType(entry); return(ConvertToContentItem(entry, contentType, publishingTarget)); }
public ContentType GetContentType(ContentItemData entry) { var contentTypeId = (string)entry["sys"].contentType.sys.id.Value.ToString(); return(GetContentType((string)contentTypeId)); }
private string GetContentItemLanguage(ContentItemData entry) => entry["sys"].locale;
private string GetContentItemId(ContentItemData entry) => entry["sys"].id;
private ContentItemField AdaptField(ContentItemData entry, Field field) { return(_fieldAdapters.ResolveAdapter(field.Type).ReadField(entry.GetField(field.Id), field)); }
private dynamic GetFieldValue(ContentItemData currentItem, ContentItemFields entry, Field field) { return(_fieldAdapters.ResolveAdapter(field.Type).WriteField(currentItem.GetField(field.Id), field, entry.GetField(field.Id))); }
private dynamic GetFieldValue(ContentItemData currentItem, ContentItem entry, Field field) { return(GetFieldValue(currentItem, entry.Fields, field)); }