/// <summary> /// Creates a new instance of <see cref="TypeMappingInfo" /> with the given <see cref="ValueConverterInfo" />. /// </summary> /// <param name="source"> The source info. </param> /// <param name="builtInConverter"> The converter to apply. </param> protected TypeMappingInfo( [NotNull] TypeMappingInfo source, ValueConverterInfo builtInConverter) { Check.NotNull(source, nameof(source)); Property = source.Property; ModelClrType = source.ModelClrType; ConfiguredProviderClrType = source.ConfiguredProviderClrType; IsRowVersion = source.IsRowVersion; IsKeyOrIndex = source.IsKeyOrIndex; if (source._customConverter != null) { _customConverter = source._customConverter; ValueConverterInfo = new ValueConverterInfo( _customConverter.ModelClrType, builtInConverter.ProviderClrType, i => _customConverter.ComposeWith(builtInConverter.Create()), builtInConverter.MappingHints == null ? _customConverter.MappingHints : builtInConverter.MappingHints.With(_customConverter.MappingHints)); } else { ValueConverterInfo = builtInConverter; } // ReSharper disable once VirtualMemberCallInConstructor var mappingHints = ValueConverterInfo?.MappingHints; Size = source.Size ?? mappingHints?.Size; IsUnicode = source.IsUnicode ?? mappingHints?.IsUnicode; Scale = source.Scale ?? mappingHints?.Scale; Precision = source.Precision ?? mappingHints?.Precision; ProviderClrType = CreateProviderClrType(); }
/// <summary> /// Creates a new instance of <see cref="TypeMappingInfo" /> with the given <see cref="ValueConverterInfo" />. /// </summary> /// <param name="source"> The source info. </param> /// <param name="builtInConverter"> The converter to apply. </param> protected TypeMappingInfo( [NotNull] TypeMappingInfo source, ValueConverterInfo builtInConverter) { Check.NotNull(source, nameof(source)); Property = source.Property; ModelClrType = source.ModelClrType; StoreClrType = source.StoreClrType; IsRowVersion = source.IsRowVersion; IsKeyOrIndex = source.IsKeyOrIndex; if (source._customConverter != null) { _customConverter = source._customConverter; ValueConverterInfo = new ValueConverterInfo( _customConverter.ModelType, builtInConverter.StoreClrType, i => _customConverter.ComposeWith(builtInConverter.Create()), _customConverter.MappingHints.With(builtInConverter.MappingHints)); } else { ValueConverterInfo = builtInConverter; } // ReSharper disable once VirtualMemberCallInConstructor var mappingHints = ValueConverterInfo?.MappingHints ?? default; Size = CalculateSize(mappingHints, source.Size ?? mappingHints.Size); IsUnicode = source.IsUnicode ?? mappingHints.IsUnicode; IsFixedLength = source.IsFixedLength ?? mappingHints.IsFixedLength; Scale = source.Scale ?? mappingHints.Scale; Precision = source.Precision ?? mappingHints.Precision; }