/// <summary> /// Creates a new instance of this converter. /// </summary> /// <param name="mappingHints"> /// Hints that can be used by the <see cref="ITypeMappingSource" /> to create data types with appropriate /// facets for the converted data. /// </param> public IPAddressToStringConverter([CanBeNull] ConverterMappingHints mappingHints = null) : base( ToString(), ToIPAddress(), _defaultHints.With(mappingHints)) { }
/// <summary> /// Creates a new instance of this converter. This converter preserves order. /// </summary> /// <param name="mappingHints"> /// Hints that can be used by the <see cref="ITypeMappingSource" /> to create data types with appropriate /// facets for the converted data. /// </param> public CharToStringConverter([CanBeNull] ConverterMappingHints mappingHints = null) : base( ToString(), ToChar(), _defaultHints.With(mappingHints)) { }
/// <summary> /// Creates a new instance of this converter. /// </summary> /// <param name="mappingHints"> /// Hints that can be used by the <see cref="ITypeMappingSource" /> to create data types with appropriate /// facets for the converted data. /// </param> public TimeSpanToStringConverter([CanBeNull] ConverterMappingHints mappingHints = null) : base( v => v.ToString("c"), v => v == null ? default : TimeSpan.Parse(v, CultureInfo.InvariantCulture), _defaultHints.With(mappingHints)) { }
/// <summary> /// Creates a new instance of this converter. /// </summary> /// <param name="mappingHints"> /// Hints that can be used by the <see cref="ITypeMappingSource" /> to create data types with appropriate /// facets for the converted data. /// </param> public IPAddressToBytesConverter([CanBeNull] ConverterMappingHints mappingHints = null) : base( v => v == null ? default : v.GetAddressBytes(), v => v == null ? default : new IPAddress(v), _defaultHints.With(mappingHints)) { }
/// <summary> /// Creates a new instance of this converter. /// </summary> /// <param name="mappingHints"> /// Hints that can be used by the <see cref="ITypeMappingSource"/> to create data types with appropriate /// facets for the converted data. /// </param> public DateTimeOffsetToStringConverter([CanBeNull] ConverterMappingHints mappingHints = null) : base( v => v.ToString(@"yyyy\-MM\-dd HH\:mm\:ss.FFFFFFFzzz"), v => v == null ? default : DateTimeOffset.Parse(v, CultureInfo.InvariantCulture), _defaultHints.With(mappingHints)) { }
/// <summary> /// Creates a new instance of this converter. /// </summary> /// <param name="mappingHints"> /// Hints that can be used by the <see cref="ITypeMappingSource" /> to create data types with appropriate /// facets for the converted data. /// </param> public GuidToStringConverter([CanBeNull] ConverterMappingHints mappingHints = null) : base( v => v.ToString("D"), v => v == null ? Guid.Empty : new Guid(v), _defaultHints.With(mappingHints)) { }
/// <summary> /// <para> /// Creates a new instance of this converter. /// </para> /// <para> /// This converter does not preserve order because the ordering of bits in /// the standard binary representation of a GUID does not match the ordering /// in the standard string representation. /// </para> /// </summary> /// <param name="mappingHints"> /// Hints that can be used by the <see cref="ITypeMappingSource" /> to create data types with appropriate /// facets for the converted data. /// </param> public GuidToBytesConverter([CanBeNull] ConverterMappingHints mappingHints = null) : base( v => v.ToByteArray(), v => v == null ? Guid.Empty : new Guid(v), _defaultHints.With(mappingHints)) { }
/// <summary> /// Creates a new instance of this converter. This converter preserves order. /// </summary> /// <param name="mappingHints"> /// Hints that can be used by the <see cref="ITypeMappingSource"/> to create data types with appropriate /// facets for the converted data. /// </param> public CharToStringConverter([CanBeNull] ConverterMappingHints mappingHints = null) : base( v => string.Format(CultureInfo.InvariantCulture, "{0}", v), v => v != null && v.Length >= 1 ? v[0] : (char)0, _defaultHints.With(mappingHints)) { }
/// <summary> /// Creates a new instance of this converter. /// </summary> /// <param name="mappingHints"> /// Hints that can be used by the <see cref="ITypeMappingSource" /> to create data types with appropriate /// facets for the converted data. /// </param> public DateTimeOffsetToBytesConverter([CanBeNull] ConverterMappingHints mappingHints = null) : base( v => ToBytes(v), v => v == null ? default : FromBytes(v), _defaultHints.With(mappingHints)) { }
public IPAddressToBytesConverter([CanBeNull] ConverterMappingHints?mappingHints = null) : base( // TODO-NULLABLE: Null is already sanitized externally, clean up as part of #13850 v => v == null ? default ! : v.GetAddressBytes(), v => v == null ? default ! : new IPAddress(v), _defaultHints.With(mappingHints)) { }
/// <summary> /// Creates a new instance of this converter. /// </summary> /// <param name="mappingHints"> /// Hints that can be used by the <see cref="ITypeMappingSource"/> to create data types with appropriate /// facets for the converted data. /// </param> public NumberToStringConverter( [CanBeNull] ConverterMappingHints mappingHints = null) : base( ToStringExpression(), ToIntegerExpression(), _defaultHints.With(mappingHints)) { }
public NumberToBytesConverter([CanBeNull] ConverterMappingHints?mappingHints = null) : base(ToBytes(), ToNumber(), _defaultHints.With(mappingHints)) { }