private void Add(string error, string memberName, bool isIndex) { memberName = ResolveMemberName(memberName, isIndex); if (string.IsNullOrEmpty(memberName)) { NonMemberErrors = NonMemberErrors.Concat(new string[] { error }); } else { TryGetValue(memberName, out IEnumerable <string> memberErrors); this[memberName] = (memberErrors ?? Enumerable.Empty <string>()).Concat(new string[] { error }); } }
private void Add(ModelErrorDictionary other, string memberName, bool isIndex) { memberName = ResolveMemberName(memberName, isIndex); if (other.NonMemberErrors.Any()) { if (string.IsNullOrEmpty(memberName)) { NonMemberErrors = NonMemberErrors.Concat(other.NonMemberErrors); } else { if (!TryGetValue(memberName, out IEnumerable <string> memberErrors)) { memberErrors = Enumerable.Empty <string>(); } this[memberName] = memberErrors.Concat(other.NonMemberErrors); } } if (other.SelectMany(kvp => kvp.Value).Any()) { foreach (var kvp in other) { if (string.IsNullOrEmpty(memberName)) { this[kvp.Key] = kvp.Value; } else { var memberPath = memberName; if (!IsMemberPathPartIndex(kvp.Key.Split('.').First())) { memberPath += "."; } memberPath += kvp.Key; this[memberPath] = kvp.Value; } } } }