/// <summary> /// Maps the properties from <paramref name="source"/> to <paramref name="target"/>. /// </summary> /// <param name="context">The <see cref="IMansionContext"/>.</param> /// <param name="source">The <see cref="Hit"/>.</param> /// <param name="property">The <see cref="JProperty"/>.</param> /// <param name="target">The <see cref="IPropertyBag"/>.</param> protected override void DoMap(IMansionContext context, Hit source, JProperty property, IPropertyBag target) { // null check if (property.Value == null) return; // expect an array var values = (JArray) property.Value; target.Set(property.Name, string.Join(",", values.Select(value => value.Value<string>()).ToArray())); }
/// <summary> /// Maps the properties from <paramref name="source"/> to <paramref name="target"/>. /// </summary> /// <param name="context">The <see cref="IMansionContext"/>.</param> /// <param name="source">The <see cref="Hit"/>.</param> /// <param name="property">The <see cref="JProperty"/>.</param> /// <param name="target">The <see cref="IPropertyBag"/>.</param> public void Map(IMansionContext context, Hit source, JProperty property, IPropertyBag target) { // validate arguments if (context == null) throw new ArgumentNullException("context"); if (source == null) throw new ArgumentNullException("source"); if (property == null) throw new ArgumentNullException("property"); if (target == null) throw new ArgumentNullException("target"); // invoke template method DoMap(context, source, property, target); }
/// <summary> /// Maps the properties from <paramref name="source"/> to <paramref name="target"/>. /// </summary> /// <param name="context">The <see cref="IMansionContext"/>.</param> /// <param name="source">The <see cref="Hit"/>.</param> /// <param name="property">The <see cref="JProperty"/>.</param> /// <param name="target">The <see cref="IPropertyBag"/>.</param> protected override void DoMap(IMansionContext context, Hit source, JProperty property, IPropertyBag target) { Map(property, target); }
/// <summary> /// Maps the properties from <paramref name="source"/> to <paramref name="target"/>. /// </summary> /// <param name="context">The <see cref="IMansionContext"/>.</param> /// <param name="source">The <see cref="Hit"/>.</param> /// <param name="property">The <see cref="JProperty"/>.</param> /// <param name="target">The <see cref="IPropertyBag"/>.</param> protected abstract void DoMap(IMansionContext context, Hit source, JProperty property, IPropertyBag target);