public static void GenerateDefaultValues(this ContentData data, Schema schema, PartitionResolver partitionResolver) { Guard.NotNull(schema, nameof(schema)); Guard.NotNull(partitionResolver, nameof(partitionResolver)); foreach (var field in schema.Fields) { var fieldData = data.GetOrCreate(field.Name, _ => new ContentFieldData()); if (fieldData != null) { var partitioning = partitionResolver(field.Partitioning); foreach (var partitionKey in partitioning.AllKeys) { Enrich(field, fieldData, partitionKey); } if (fieldData.Count > 0) { data[field.Name] = fieldData; } } } }
public void Enrich(ContentData data) { Guard.NotNull(data, nameof(data)); Guard.NotEmpty(languages, nameof(languages)); foreach (var field in schema.FieldsByName.Values) { var fieldData = data.GetOrCreate(field.Name, k => new ContentFieldData()); if (field.RawProperties.IsLocalizable) { foreach (var language in languages) { Enrich(field, fieldData, language); } } else { Enrich(field, fieldData, Language.Invariant); } if (fieldData.Count > 0) { data.AddField(field.Name, fieldData); } } }
public async Task ValidateAsync(ContentData data) { Guard.NotNull(data, nameof(data)); ValidateUnknownFields(data); foreach (var field in schema.FieldsByName.Values) { var fieldData = data.GetOrCreate(field.Name, k => new ContentFieldData()); await ValidateFieldAsync(field, fieldData); } }
public void Enrich(ContentData data) { Guard.NotNull(data, nameof(data)); foreach (var field in schema.FieldsByName.Values) { var fieldData = data.GetOrCreate(field.Name, k => new ContentFieldData()); var fieldPartition = partitionResolver(field.Paritioning); foreach (var partitionItem in fieldPartition) { Enrich(field, fieldData, partitionItem); } if (fieldData.Count > 0) { data.AddField(field.Name, fieldData); } } }
public async Task ValidateAsync(ContentData data) { Guard.NotNull(data, nameof(data)); ValidateUnknownFields(data); foreach (var field in schema.FieldsByName.Values) { var fieldData = data.GetOrCreate(field.Name, k => new ContentFieldData()); if (field.RawProperties.IsLocalizable) { await ValidateLocalizableFieldAsync(field, fieldData); } else { await ValidateNonLocalizableField(field, fieldData); } } }
public void Enrich(ContentData <T> data) { Guard.NotNull(data, nameof(data)); foreach (var field in schema.Fields) { var fieldKey = data.GetKey(field); var fieldData = data.GetOrCreate(fieldKey, k => new ContentFieldData()); var fieldPartition = partitionResolver(field.Paritioning); foreach (var partitionItem in fieldPartition) { Enrich(field, fieldData, partitionItem); } if (fieldData.Count > 0) { data[fieldKey] = fieldData; } } }
public void Enrich(ContentData data) { Guard.NotNull(data, nameof(data)); foreach (var field in schema.Fields) { var fieldData = data.GetOrCreate(field.Name, _ => new ContentFieldData()); if (fieldData != null) { var partitioning = partitionResolver(field.Partitioning); foreach (var partitionKey in partitioning.AllKeys) { Enrich(field, fieldData, partitionKey); } if (fieldData.Count > 0) { data[field.Name] = fieldData; } } } }