Esempio n. 1
0
 /// <summary>
 ///     Creates a new instance of this converter.
 /// </summary>
 /// <param name="mappingHints">
 ///     Hints that can be used by the type mapper to create data types with appropriate
 ///     facets for the converted data.
 /// </param>
 public DateTimeOffsetToStringConverter(ConverterMappingHints mappingHints = default)
     : base(
         v => v.ToString(@"yyyy\-MM\-dd HH\:mm\:ss.FFFFFFFzzz"),
         v => v == null ? default : DateTimeOffset.Parse(v, CultureInfo.InvariantCulture),
         mappingHints.With(_defaultHints))
 {
 }
Esempio n. 2
0
 /// <summary>
 ///     Creates a new instance of this converter.
 /// </summary>
 /// <param name="mappingHints">
 ///     Hints that can be used by the type mapper to create data types with appropriate
 ///     facets for the converted data.
 /// </param>
 public TimeSpanToStringConverter(ConverterMappingHints mappingHints = default)
     : base(
         v => v.ToString("c"),
         v => v == null ? default : TimeSpan.Parse(v, CultureInfo.InvariantCulture),
         mappingHints.With(_defaultHints))
 {
 }
Esempio n. 3
0
 /// <summary>
 ///     Creates a new instance of this converter. This converter preserves order.
 /// </summary>
 /// <param name="mappingHints">
 ///     Hints that can be used by the type mapper to create data types with appropriate
 ///     facets for the converted data.
 /// </param>
 public CharToStringConverter(ConverterMappingHints mappingHints = default)
     : base(
         v => string.Format(CultureInfo.InvariantCulture, "{0}", v),
         v => v != null && v.Length >= 1 ? v[0] : (char)0,
         mappingHints.With(_defaultHints))
 {
 }
Esempio n. 4
0
 /// <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(ConverterMappingHints mappingHints = default)
     : base(
         v => ToBytes(v),
         v => v == null ? default : FromBytes(v),
         mappingHints.With(_defaultHints))
 {
 }
 /// <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(ConverterMappingHints mappingHints = default)
     : base(
         v => v.ToByteArray(),
         v => v == null ? Guid.Empty : new Guid(v),
         mappingHints.With(_defaultHints))
 {
 }
Esempio n. 6
0
 /// <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(ConverterMappingHints mappingHints = default)
     : base(
         v => v.ToString("D"),
         v => v == null ? Guid.Empty : new Guid(v),
         mappingHints.With(_defaultHints))
 {
 }
Esempio n. 7
0
 /// <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 BytesToStringConverter(
     ConverterMappingHints mappingHints = default)
     : base(
         v => v == null ? null : Convert.ToBase64String(v),
         v => v == null ? null : Convert.FromBase64String(v),
         mappingHints.With(_defaultHints))
 {
 }
 /// <summary>
 ///     Creates a new instance of this converter.
 /// </summary>
 /// <param name="mappingHints">
 ///     Hints that can be used by the type mapper to create data types with appropriate
 ///     facets for the converted data.
 /// </param>
 public NumberToStringConverter(
     ConverterMappingHints mappingHints = default)
     : base(
         ToStringExpression(),
         ToIntegerExpression(),
         mappingHints.With(_defaultHints))
 {
 }
 /// <summary>
 ///     Creates a new instance of this converter. A case-insensitive first character test is used
 ///     when converting from the store.
 /// </summary>
 /// <param name="falseValue"> The string to use for <c>false</c>. </param>
 /// <param name="trueValue"> The string to use for <c>true</c>. </param>
 /// <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 BoolToStringConverter(
     [NotNull] string falseValue,
     [NotNull] string trueValue,
     ConverterMappingHints mappingHints = default)
     : base(
         Check.NotEmpty(falseValue, nameof(falseValue)),
         Check.NotEmpty(trueValue, nameof(trueValue)),
         FromStore(trueValue),
         mappingHints.With(new ConverterMappingHints(size: Math.Max(falseValue.Length, trueValue.Length))))
 {
 }
 /// <summary>
 ///     Creates a new instance of this converter. This converter does not preserve order.
 /// </summary>
 /// <param name="mappingHints">
 ///     Hints that can be used by the type mapper to create data types with appropriate
 ///     facets for the converted data.
 /// </param>
 public EnumToStringConverter(ConverterMappingHints mappingHints = default)
     : base(v => v.ToString(), ToEnum(), mappingHints.With(_defaultHints))
 {
 }
Esempio n. 11
0
 /// <summary>
 ///     <para>
 ///         Creates a new instance of this converter.
 ///     </para>
 ///     <para>
 ///         This converter supports <see cref="double" />, <see cref="float" />, <see cref="decimal" />,
 ///         <see cref="int" />, <see cref="long" />, <see cref="short" />, <see cref="byte" />,
 ///         <see cref="uint" />, <see cref="ulong" />, <see cref="ushort" />, <see cref="sbyte" />,
 ///         and <see cref="char" />.
 ///     </para>
 /// </summary>
 /// <param name="mappingHints">
 ///     Hints that can be used by the type mapper to create data types with appropriate
 ///     facets for the converted data.
 /// </param>
 public NumberToBytesConverter(ConverterMappingHints mappingHints = default)
     : base(ToBytes(), ToNumber(), mappingHints.With(_defaultHints))
 {
 }