@ -11,7 +11,7 @@ public static class ExtensibleObjectMapper
/// <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>
@ -34,14 +34,29 @@ public static class ExtensibleObjectMapper
Check . NotNull ( source , nameof ( source ) ) ;
Check . NotNull ( destination , nameof ( destination ) ) ;
ExtensibleObjectMapper . MapExtraPropertiesTo (
typeof ( TSource ) ,
typeof ( TDestination ) ,
source . ExtraProperties ,
destination . ExtraProperties ,
definitionChecks ,
ignoredProperties
) ;
var sourceType = typeof ( TSource ) ;
var destinationType = typeof ( TDestination ) ;
Check . AssignableTo < IHasExtraProperties > ( sourceType , nameof ( sourceType ) ) ;
Check . AssignableTo < IHasExtraProperties > ( destinationType , nameof ( destinationType ) ) ;
Check . NotNull ( source . ExtraProperties , nameof ( source . ExtraProperties ) ) ;
Check . NotNull ( destination . ExtraProperties , nameof ( destination . ExtraProperties ) ) ;
var sourceObjectExtension = ObjectExtensionManager . Instance . GetOrNull ( sourceType ) ;
var destinationObjectExtension = ObjectExtensionManager . Instance . GetOrNull ( destinationType ) ;
foreach ( var keyValue in source . ExtraProperties )
{
if ( CanMapProperty (
keyValue . Key ,
sourceObjectExtension ,
destinationObjectExtension ,
definitionChecks ,
ignoredProperties ) )
{
destination . SetProperty ( keyValue . Key , keyValue . Value ) ;
}
}
}
/// <summary>
@ -80,7 +95,7 @@ public static class ExtensibleObjectMapper
/// <summary>
/// Copies extra properties from the <paramref name="sourceDictionary"/> object
/// to the <paramref name="destinationDictionary"/> object.
///
///
/// Checks property definitions (over the <see cref="ObjectExtensionManager"/>)
/// based on the <paramref name="definitionChecks"/> preference.
/// </summary>