예제 #1
0
        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);
        }
예제 #2
0
        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);
                }
            }
        }