private static ContentData MergeTo(ContentData target, params ContentData[] sources) { Guard.NotEmpty(sources, nameof(sources)); if (sources.Length == 1 || sources.Skip(1).All(x => ReferenceEquals(x, sources[0]))) { return(sources[0]); } foreach (var source in sources) { foreach (var(key, contentFieldData) in source) { if (contentFieldData != null) { var fieldValue = target.GetOrAdd(key, x => new ContentFieldData()); if (fieldValue != null) { foreach (var(fieldName, value) in contentFieldData) { fieldValue[fieldName] = value; } } } } } return(target); }
private static ContentData MergeTo(ContentData target, params ContentData[] sources) { Guard.NotEmpty(sources); if (sources.Length == 1 || sources.Skip(1).All(x => ReferenceEquals(x, sources[0]))) { return(sources[0]); } foreach (var source in sources) { foreach (var(fieldName, sourceFieldData) in source) { if (sourceFieldData == null) { continue; } var targetFieldData = target.GetOrAdd(fieldName, _ => new ContentFieldData()); if (targetFieldData == null) { continue; } foreach (var(partition, value) in sourceFieldData) { targetFieldData[partition] = value; } } } return(target); }