/// <summary> /// Gets a nested value. /// </summary> /// <param name="tokenValue">The nested token value.</param> /// <param name="map">The field mapping.</param> /// <param name="target">The target object to populate with mapped key/values.</param> private void GetNestedValue(IEnumerable<object> tokenValue, MappedField map, XmlNode target) { XmlNode repeaterNode = target.AddElement(map.Target); foreach (object row in tokenValue) { XmlNode rowNode = repeaterNode.AddElement(HttpResources.XmlRepeaterRowIdentifier); var fields = row as NestedDictionary; if (fields != null) { foreach (KeyValuePair<string, object> field in fields) { rowNode.AddElement(field.Key, field.Value.ToString()); } } else { rowNode.AddElement(row.ToString()); } } }
/// <summary> /// Gets a nested value. /// </summary> /// <param name="tokenValue">The nested token value.</param> /// <param name="map">The field mapping.</param> /// <param name="target">The target object to populate with mapped key/values.</param> private void GetNestedValue(IEnumerable<object> tokenValue, MappedField map, Dictionary<string, string> target) { var i = 0; foreach (object row in tokenValue) { var fields = row as NestedDictionary; if (fields != null) { foreach (KeyValuePair<string, object> field in fields) { target.Add(string.Format("{0}-{1}-{2}", map.Target, i + 1, field.Key), field.Value.ToString()); } } else { target.Add(string.Format("{0}-{1}", map.Target, i + 1), row.ToString()); } i++; } }
/// <summary> /// Populates <paramref name="target"/> with values from <paramref name="response"/> as defined by <paramref name="map"/>. /// </summary> /// <param name="response">The response object from which to get values.</param> /// <param name="map">A field map definition.</param> /// <param name="target">The target object to populate with mapped key/values.</param> private void MapPropertyField(HttpWebResponse response, MappedField map, ApplicationData target) { PropertyInfo info = response.GetType().GetProperty(map.Source); object propertyValue = info.GetValue(response); target.SetValue(map.Target, propertyValue); }