コード例 #1
0
        public static IMappingExpression <TSource, TDestination> MapExtraProperties <TSource, TDestination> (
            this IMappingExpression <TSource, TDestination> mappingExpression,
            MappingPropertyDefinitionChecks?definitionChecks = null,
            string[] ignoredProperties = null)
            where TDestination : IHasExtraProperties
            where TSource : IHasExtraProperties
        {
            return(mappingExpression
                   .ForMember(
                       x => x.ExtraProperties,
                       y => y.MapFrom(
                           (source, destination, extraProps) => {
                var result = extraProps.IsNullOrEmpty() ?
                             new Dictionary <string, object> () :
                             new Dictionary <string, object> (extraProps);

                ExtensibleObjectMapper
                .MapExtraPropertiesTo <TSource, TDestination> (
                    source.ExtraProperties,
                    result,
                    definitionChecks,
                    ignoredProperties
                    );

                return result;
            })
                       ));
        }
コード例 #2
0
 /// <summary>
 /// Copies extra properties from the <paramref name="source"/> object
 /// to the <paramref name="destination"/> object.
 ///
 /// Checks property definitions (over the <see cref="ObjectExtensionManager"/>)
 /// based on the <paramref name="definitionChecks"/> preference.
 /// </summary>
 /// <typeparam name="TSource">Source class type</typeparam>
 /// <typeparam name="TDestination">Destination class type</typeparam>
 /// <param name="source">The source object</param>
 /// <param name="destination">The destination object</param>
 /// <param name="definitionChecks">
 ///     Controls which properties to map.
 /// </param>
 /// <param name="ignoredProperties">Used to ignore some properties</param>
 public static void MapExtraPropertiesTo <TSource, TDestination>(
     [NotNull] this TSource source,
     [NotNull] TDestination destination,
     MappingPropertyDefinitionChecks?definitionChecks = null,
     string[] ignoredProperties = null)
     where TSource : IHasExtraProperties
     where TDestination : IHasExtraProperties
 {
     ExtensibleObjectMapper.MapExtraPropertiesTo(
         source,
         destination,
         definitionChecks,
         ignoredProperties
         );
 }
コード例 #3
0
    /// <summary>
    /// Copies extra properties from the <paramref name="source"/> object
    /// to the <paramref name="destination"/> object.
    ///
    /// Checks property definitions (over the <see cref="ObjectExtensionManager"/>)
    /// based on the <paramref name="definitionChecks"/> preference.
    /// </summary>
    /// <typeparam name="TSource">Source class type</typeparam>
    /// <typeparam name="TDestination">Destination class type</typeparam>
    /// <param name="source">The source object</param>
    /// <param name="destination">The destination object</param>
    /// <param name="definitionChecks">
    ///     Controls which properties to map.
    /// </param>
    /// <param name="ignoredProperties">Used to ignore some properties</param>
    public static void MapExtraPropertiesTo <TSource, TDestination>(
        [NotNull] TSource source,
        [NotNull] TDestination destination,
        MappingPropertyDefinitionChecks?definitionChecks = null,
        string[] ignoredProperties = null)
        where TSource : IHasExtraProperties
        where TDestination : IHasExtraProperties
    {
        Check.NotNull(source, nameof(source));
        Check.NotNull(destination, nameof(destination));

        ExtensibleObjectMapper.MapExtraPropertiesTo(
            typeof(TSource),
            typeof(TDestination),
            source.ExtraProperties,
            destination.ExtraProperties,
            definitionChecks,
            ignoredProperties
            );
    }