private static void MapFailures(IEnumerable <RuleViolation> validationFailures, IValidatedObject validatedObject) { foreach (var validationFailure in validationFailures) { validatedObject.AddDataErrorInfo( new DataErrorInfo( validationFailure.Message, ErrorLevel.Error, PropertyNameMapper.GetDestinationPropertyNames(validationFailure.OffendingObject.GetType(), validatedObject.GetType(), validationFailure.PropertyNames))); } }
/// <summary> /// Handles the specified request. /// </summary> /// <param name="request">The request.</param> /// <returns>A <see cref="Response"/></returns> public override Response Handle(GetNHibernateInformationRequest request) { var response = CreateTypedResponse(); var memberChain = PropertyNameMapper.GetSourcePropertyChain(request.DataTransferObject.GetType(), request.PropertyName).ToList(); if (memberChain.Count() > 0) { var dbInfo = _nHibernateInformationService.GetPropertyChainDatabaseInformation( memberChain.ElementAt(0).DeclaringType, memberChain); response.DbInfoDto = dbInfo; } else { response.DbInfoDto = new DbInfoDto(); response.DbInfoDto.AddDataErrorInfo(new DataErrorInfo("Cannot find property mapping.", ErrorLevel.Error)); } return(response); }