Exemplo n.º 1
0
        public static ContentData Convert(this ContentData content, Schema schema, params FieldConverter[] converters)
        {
            Guard.NotNull(schema, nameof(schema));

            var result = new ContentData(content.Count);

            if (converters == null || converters.Length == 0)
            {
                return(result);
            }

            foreach (var(fieldName, fieldData) in content)
            {
                if (fieldData == null || !schema.FieldsByName.TryGetValue(fieldName, out var field))
                {
                    continue;
                }

                ContentFieldData?newData = fieldData;

                if (newData != null)
                {
                    newData = ConvertData(field, newData, converters);
                }

                if (newData != null)
                {
                    result.Add(field.Name, newData);
                }
            }

            return(result);
        }