private List <ReverseCoverageResult> MapUniqueResults(List <ModelValidationResult> validationResults) { var uniqueResults = new List <ReverseCoverageResult>(); foreach (var result in validationResults) { if (!uniqueResults.Any(r => r.Model.GetType() == result.Model.GetType())) { var newResult = new ReverseCoverageResult(); newResult.Model = result.Model; newResult.ModelFullClassName = result.Model.GetType().FullName; newResult.ModelShortClassName = result.Model.GetType().Name; foreach (var propResult in result.Properties) { var newPropResult = new ReverseCoveragePropertyResult(); if (propResult.Src != null) { newPropResult.SrcPropertyName = propResult.Src.Name; newPropResult.SrcPropertyValue = ConvertUtils.ToString(propResult.Src.Value); } if (propResult.Dst != null) { newPropResult.DstPropertyName = propResult.Dst.Name; newPropResult.DstPropertyValue = ConvertUtils.ToString(propResult.Dst.Value); } newPropResult.IsValid = propResult.IsValid; newPropResult.Message = propResult.Message; newResult.Properties.Add(newPropResult); } uniqueResults.Add(newResult); } } uniqueResults = uniqueResults.OrderBy(r => r.Model.GetType().Name) .ToList(); return(uniqueResults); }
private List<ReverseCoverageResult> MapUniqueResults(List<ModelValidationResult> validationResults) { var uniqueResults = new List<ReverseCoverageResult>(); foreach (var result in validationResults) { if (!uniqueResults.Any(r => r.Model.GetType() == result.Model.GetType())) { var newResult = new ReverseCoverageResult(); newResult.Model = result.Model; newResult.ModelFullClassName = result.Model.GetType().FullName; newResult.ModelShortClassName = result.Model.GetType().Name; foreach (var propResult in result.Properties) { var newPropResult = new ReverseCoveragePropertyResult(); if (propResult.Src != null) { newPropResult.SrcPropertyName = propResult.Src.Name; newPropResult.SrcPropertyValue = ConvertUtils.ToString(propResult.Src.Value); } if (propResult.Dst != null) { newPropResult.DstPropertyName = propResult.Dst.Name; newPropResult.DstPropertyValue = ConvertUtils.ToString(propResult.Dst.Value); } newPropResult.IsValid = propResult.IsValid; newPropResult.Message = propResult.Message; newResult.Properties.Add(newPropResult); } uniqueResults.Add(newResult); } } uniqueResults = uniqueResults.OrderBy(r => r.Model.GetType().Name) .ToList(); return uniqueResults; }