public static ContentEmbedded ToModel(this RestContentEmbedded restContentItem) { ContentSchema schema = restContentItem.Schema.ToModel(); ContentEmbedded contentItem = schema.CreateContentEmbedded(); foreach (var restField in restContentItem.Fields) { restField.Value.FromRestValue(restField.Key, contentItem, schema); } return(contentItem); }
public override void Read(ContentSchemaField schemaField, EmbedField contentField, BsonValue bsonValue) { string schemaName = bsonValue[ReferenceField.SchemaField].AsString; ContentSchema schema = MongoStorage.Default.GetContentSchemaAsync(schemaName).GetAwaiter().GetResult(); contentField.ContentEmbedded = schema.CreateContentEmbedded(); if (bsonValue[nameof(IContentElement.Fields)] is BsonDocument bsonDocument) { foreach (var field in bsonDocument) { field.Value.FromBsonValue(field.Name, contentField.ContentEmbedded, schema); } } }