Exemple #1
0
 public static PrintingConfig <TOwner> UsingCulture <TOwner, T>(
     this MemberPrintingConfig <TOwner, T> propConfig,
     CultureInfo culture)
     where T : IFormattable
 {
     return(propConfig.Using(x => x.ToString(null, culture)));
 }
Exemple #2
0
 public static PrintingConfig <TOwner> TrimmedToLength <TOwner>(
     this MemberPrintingConfig <TOwner, string> propConfig, int maxLength)
 {
     if (maxLength < 0)
     {
         throw new ArgumentException("maxLength must be non-negative");
     }
     return(propConfig.Using(s => maxLength > s.Length ? s : s.Substring(0, maxLength)));
 }
Exemple #3
0
 public static PrintingConfig <TOwner> TrimmedToLength <TOwner>(
     this MemberPrintingConfig <TOwner, string> propConfig, int maxLength)
 {
     return(propConfig.SetSerializer(str => str.Substring(0, Math.Min(str.Length, maxLength))));
 }
Exemple #4
0
 public static PrintingConfig <TOwner> SetCulture <TOwner, TProperty>(
     this MemberPrintingConfig <TOwner, TProperty> propConfig, CultureInfo culture)
     where TProperty : IFormattable
 {
     return(propConfig.SetSerializer(x => ((IFormattable)x).ToString("N", culture)));
 }