private static PrintingConfig <TOwner> AddCulture <TOwner>(IPropertyPrintingConfig <TOwner> inner, CultureInfo culture, Type type) { var printingConfig = inner.PrintingConfig; ((IPrintingConfig <TOwner>)printingConfig).AddTypeCulture(type, culture); return(printingConfig); }
public static PrintingConfig <TOwner> TrimmedToLength <TOwner> (this IPropertyPrintingConfig <TOwner, string> config, int trimCount) { IPrintingConfig <TOwner> parent = config.ParentConfig; var property = config.Property; parent.StringPropertyTrimmingCount.Add(property, trimCount); return((PrintingConfig <TOwner>)parent); }
private void AddCommonStringPrintingConfig(IPropertyPrintingConfig <string> printingConfig) { var printingFunction = ExtractPrintingFunction(printingConfig); stringPrintingConfig = stringPrintingConfig == null ? printingFunction : ConcatFunctions(stringPrintingConfig, printingFunction); foreach (var name in namesStringPrintingConfigs.Keys.ToArray()) { namesStringPrintingConfigs[name] = ConcatFunctions(namesStringPrintingConfigs[name], printingFunction); } }
private static PrintingConfig <TOwner> SetCulture <TOwner, TPropType> (IPropertyPrintingConfig <TOwner, TPropType> config, CultureInfo culture) { var supptortTypes = new[] { typeof(int), typeof(double), typeof(long) }; var type = typeof(TPropType); if (supptortTypes.All(t => t != type)) { throw new ArgumentException($"PropertyPrintingConfig with PropType == {type} not supported"); } IPrintingConfig <TOwner> parent = config.ParentConfig; parent.NumbersCulture[typeof(TPropType)] = culture; return((PrintingConfig <TOwner>)parent); }
private void AddStringPrintingConfigWithNames(IPropertyPrintingConfig <string> printingConfig, string name) { var printingFunction = ExtractPrintingFunction(printingConfig); Func <object, string> previousFunction; if (namesStringPrintingConfigs.TryGetValue(name, out previousFunction)) { namesStringPrintingConfigs[name] = ConcatFunctions(previousFunction, printingFunction); } else { namesStringPrintingConfigs[name] = stringPrintingConfig == null ? printingFunction : ConcatFunctions(stringPrintingConfig, printingFunction); } }
public static PrintingConfig <TOwner> TrimmedToLength <TOwner>(this PropertyPrintingConfig <TOwner, string> propConfig, int maxLen) { IPropertyPrintingConfig <TOwner, string> propertyConfig = propConfig; if (string.IsNullOrWhiteSpace(propertyConfig.PropName)) { ((IPrintingConfig <TOwner>)propertyConfig.ParentConfig).SetAverageStringLength(maxLen); } else { ((IPrintingConfig <TOwner>)propertyConfig.ParentConfig).SetStringPropertyLength(propertyConfig.PropName, maxLen); } return(((IPropertyPrintingConfig <TOwner, string>)propConfig).ParentConfig); }
public static PrintingConfig <TOwner> TrimmedToLength <TOwner>(this IPropertyPrintingConfig <TOwner, string> pc, int length) { pc.PrintingConfig.AddTrimmCut(pc.PropertyInfo, length); return(pc.PrintingConfig); }
public static IPrintingConfig <TOwner> Trimmed <TOwner>(this IPropertyPrintingConfig <string, TOwner> config, int lenght) { return(config.Using(x => x[..^ lenght]));
private Func <object, string> ExtractPrintingFunction <TProp>(IPropertyPrintingConfig <TProp> printingConfig) => x => printingConfig.PrintingFunction((TProp)x);
public DigitCulturePrintingConfig(IPropertyPrintingConfig <TOwner> propertyPrintingConfig) { printingConfig = propertyPrintingConfig.PrintingConfig; }