string IMappingEngineRunner.FormatValue(ResolutionContext context) { TypeMap contextTypeMap = context.GetContextTypeMap(); IFormatterConfiguration configuration = contextTypeMap != null ? ConfigurationProvider.GetProfileConfiguration(contextTypeMap.Profile) : ConfigurationProvider.GetProfileConfiguration(ConfigurationStore.DefaultProfileName); object valueToFormat = context.SourceValue; string formattedValue = context.SourceValue.ToNullSafeString(); var formatters = configuration.GetFormattersToApply(context); foreach (var valueFormatter in formatters) { formattedValue = valueFormatter.FormatValue(context.CreateValueContext(valueToFormat)); valueToFormat = formattedValue; } if (formattedValue == null && !((IMappingEngineRunner)this).ShouldMapSourceValueAsNull(context)) { return(string.Empty); } return(formattedValue); }
bool IMappingEngineRunner.ShouldMapSourceCollectionAsNull(ResolutionContext context) { var typeMap = context.GetContextTypeMap(); if (typeMap != null) { return(ConfigurationProvider.GetProfileConfiguration(typeMap.Profile).MapNullSourceCollectionsAsNull); } return(ConfigurationProvider.MapNullSourceCollectionsAsNull); }
bool IMappingEngineRunner.ShouldMapSourceValueAsNull(ResolutionContext context) { if (context.DestinationType.IsValueType) { return(false); } var typeMap = context.GetContextTypeMap(); if (typeMap != null) { return(ConfigurationProvider.GetProfileConfiguration(typeMap.Profile).MapNullSourceValuesAsNull); } return(ConfigurationProvider.MapNullSourceValuesAsNull); }