private DemographicAnswer MatchDemographicAnswer(Question question, IEnumerable <ResponseAnswer> responseAnswers) { var reply = new DemographicAnswer(); foreach (var responseAnswer in responseAnswers) { var propertyName = question.AnswersLookup[responseAnswer.Row].Type.ToString(); if (typeof(DemographicAnswer).GetProperty(propertyName, (BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance)) != null) { typeof(DemographicAnswer).GetProperty(propertyName, (BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance)).SetValue(reply, responseAnswer.Text); } } return(reply); }
private DemographicAnswer MatchDemographicAnswer(Question question, IEnumerable <ResponseAnswer> responseAnswers) { var reply = new DemographicAnswer(); foreach (var responseAnswer in responseAnswers) { if (responseAnswer.RowId.HasValue) { if (question.Answers.DemographicTypeLookup.ContainsKey(responseAnswer.RowId.Value)) { string propertyName = question.Answers.DemographicTypeLookup[responseAnswer.RowId.Value]; PropertyInfo property = typeof(DemographicAnswer).GetProperty(propertyName, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance); if (property != null) { property.SetValue(reply, responseAnswer.Text, null); } } } } return(reply); }
private DemographicAnswer MatchDemographicAnswer(Question question, IEnumerable<ResponseAnswer> responseAnswers) { var reply = new DemographicAnswer(); foreach (var responseAnswer in responseAnswers) { var propertyName = question.AnswersLookup[responseAnswer.Row].Type.ToString(); if (typeof(DemographicAnswer).GetProperty(propertyName, (BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance)) != null) { typeof(DemographicAnswer).GetProperty(propertyName, (BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance)).SetValue(reply, responseAnswer.Text); } } return reply; }