/// <summary> /// Specify an explicit property mapping /// </summary> /// <typeparam name="TInput">Source property type</typeparam> /// <typeparam name="TOutput">Target property type</typeparam> /// <param name="sourcePropertyExpression">Accessor for the source property to get</param> /// <param name="targetPropertyExpression">Accessor for the target property to set</param> /// <returns></returns> public ClassMap <TSource, TTarget> Specify <TInput, TOutput>(Func <TSource, TInput> sourcePropertyExpression, Expression <Func <TTarget, TOutput> > targetPropertyExpression) { var mapping = new FuncMapping <TSource, TInput, TTarget, TOutput>(sourcePropertyExpression, targetPropertyExpression); MappingStrategy.AddMapping(mapping); return(this); }
/// <summary> /// Specify an explicit property mapping /// </summary> /// <param name="sourceFieldIndex">Index of the source field to get</param> /// <param name="targetPropertyExpression">Accessor for the target property to set</param> /// <returns></returns> public CsvMap <TTarget> Specify(int souceFieldIndex, Expression <Func <TTarget, object> > targetPropertyExpression) { var mapping = new CsvFieldMapping(souceFieldIndex, targetPropertyExpression); MappingStrategy.AddMapping(mapping); return(this); }
/// <summary> /// Specify an explicit property mapping /// </summary> /// <param name="xPathQuery">XPath query for the source node to get, starting from root</param> /// <param name="targetPropertyExpression">Accessor for the target property to set</param> /// <returns></returns> public XDocumentMap <TTarget> Specify(string xPathQuery, Expression <Func <TTarget, object> > targetPropertyExpression) { var mapping = new XPathMapping(xPathQuery, targetPropertyExpression); MappingStrategy.AddMapping(mapping); return(this); }
/// <summary> /// Specify an explicit property mapping /// </summary> /// <param name="nodeType">Type of the source node - one of Element or Attribute</param> /// <param name="sourceNodeName">Name of the source node to get</param> /// <param name="targetPropertyExpression">Accessor for the target property to set</param> /// <returns></returns> public XDocumentMap <TTarget> Specify(XmlNodeType nodeType, XName sourceNodeName, Expression <Func <TTarget, object> > targetPropertyExpression) { var mapping = GetNodeMapping(nodeType, sourceNodeName, targetPropertyExpression); MappingStrategy.AddMapping(mapping); return(this); }
/// <summary> /// Specify an explicit property mapping /// </summary> /// <param name="mappingAction">Action to populate target property value</param> /// <returns></returns> protected internal Map <TSource, TTarget, TMatchingLookup> Specify(Action <TSource, TTarget> mappingAction) { var mapping = new ActionMapping <TSource, TTarget>(mappingAction); MappingStrategy.AddMapping(mapping); return(this); }
/// <summary> /// Specify an explicit property mapping /// </summary> /// <param name="sourceColumnName">Name of the source column to get</param> /// <param name="targetPropertyExpression">Accessor for the target property to set</param> /// <returns></returns> public DataReaderMap <TTarget> Specify(string sourceColumnName, Expression <Func <TTarget, object> > targetPropertyExpression) { var mapping = new DataReaderColumnMapping(sourceColumnName, targetPropertyExpression); MappingStrategy.AddMapping(mapping); return(this); }
/// <summary> /// Specify an explicit property mapping with a value conversion /// </summary> /// <typeparam name="TInput">Source property type</typeparam> /// <typeparam name="TOutput">Target property type</typeparam> /// <param name="sourceFieldIndex">Index of the source field to get</param> /// <param name="targetPropertyExpression">Accessor for the target property to set</param> /// <param name="conversion">Conversion function to apply to the source value</param> /// <returns></returns> public CsvMap <TTarget> Specify <TInput, TOutput>(int souceFieldIndex, Expression <Func <TTarget, TOutput> > targetPropertyExpression, Func <TInput, TOutput> conversion) { var mapping = new CsvFieldMapping(souceFieldIndex, targetPropertyExpression); mapping.SetConversion <TInput, TOutput>(conversion); MappingStrategy.AddMapping(mapping); return(this); }
/// <summary> /// Specify an explicit property mapping with a value conversion /// </summary> /// <exception cref="ArgumentException"> /// Thrown if XmlNodeType is not Element or Attribute /// </exception> /// <typeparam name="TInput">Source property type</typeparam> /// <typeparam name="TOutput">Target property type</typeparam> /// <param name="nodeType">Type of the source node - one of Element or Attribute</param> /// <param name="sourceNodeName">Name of the source node to get</param> /// <param name="targetPropertyExpression">Accessor for the target property to set</param> /// <param name="conversion">Conversion function to apply to the source value</param> /// <returns></returns> public XDocumentMap <TTarget> Specify <TInput, TOutput>(XmlNodeType nodeType, XName sourceNodeName, Expression <Func <TTarget, TOutput> > targetPropertyExpression, Func <TInput, TOutput> conversion) { var mapping = GetNodeMapping(nodeType, sourceNodeName, targetPropertyExpression); mapping.SetConversion <TInput, TOutput>(conversion); MappingStrategy.AddMapping(mapping); return(this); }
/// <summary> /// Specify an explicit property mapping with a value conversion /// </summary> /// <typeparam name="TInput">Source property type</typeparam> /// <typeparam name="TOutput">Target property type</typeparam> /// <param name="xPathQuery">XPath query for the source node to get, starting from root</param> /// <param name="targetPropertyExpression">Accessor for the target property to set</param> /// <param name="conversion">Conversion function to apply to the source value</param> /// <returns></returns> public XDocumentMap <TTarget> Specify <TInput, TOutput>(string xPathQuery, Expression <Func <TTarget, TOutput> > targetPropertyExpression, Func <TInput, TOutput> conversion) { var mapping = new XPathMapping(xPathQuery, targetPropertyExpression); mapping.SetConversion <TInput, TOutput>(conversion); MappingStrategy.AddMapping(mapping); return(this); }
/// <summary> /// Specify an explicit property mapping with a value conversion /// </summary> /// <typeparam name="TInput">Source property type</typeparam> /// <typeparam name="TOutput">Target property type</typeparam> /// <param name="sourceColumnName">Name of the source column to get</param> /// <param name="targetPropertyExpression">Accessor for the target property to set</param> /// <param name="conversion">Conversion function to apply to the source value</param> /// <returns></returns> public DataReaderMap <TTarget> Specify <TInput, TOutput>(string sourceColumnName, Expression <Func <TTarget, TOutput> > targetPropertyExpression, Func <TInput, TOutput> conversion) { var mapping = new DataReaderColumnMapping(sourceColumnName, targetPropertyExpression); mapping.SetConversion <TInput, TOutput>(conversion); MappingStrategy.AddMapping(mapping); return(this); }