public static PrintingConfig <TOwner> Using <TOwner>(this PropertyPrintingConfig <TOwner, DateTime> propConfig, CultureInfo culture)
        {
            var propertyConfig = (IPropertyPrintingConfig <TOwner, DateTime>)propConfig;

            propertyConfig.ParentConfig.AddCultureForMember(typeof(DateTime), culture);
            return(propertyConfig.ParentConfig);
        }
        public static PrintingConfig <TOwner> Using <TOwner, TPropType>(this PropertyPrintingConfig <TOwner, TPropType> propConfig, CultureInfo culture) where TPropType : IFormattable
        {
            var parentConfig = ((IPropertyPrintingConfig <TOwner, TPropType>)propConfig).ParentConfig;

            ((IPrintingConfig)parentConfig).TypeCultures[typeof(TPropType)] = culture;
            return(parentConfig);
        }
 public static PrintingConfig <TOwner> TrimmedToLength <TOwner>(
     this PropertyPrintingConfig <TOwner, string> propConfig, int maxLen)
 {
     return(maxLen < 0
         ? propConfig.Using(s => "")
         : propConfig.Using(s => s.Substring(0, Math.Min(s.Length, maxLen))));
 }
Example #4
0
        public static PrintingConfig <TOwner> Using <TOwner, T>(this PropertyPrintingConfig <TOwner, T> propertyPrintingConfig,
                                                                CultureInfo cultureInfo) where T : IFormattable
        {
            var parentConfig = ((IPropertyPrintingConfig <TOwner, T>)propertyPrintingConfig).ParentConfig;

            return(parentConfig.AddNumericTypeCultureInfo(typeof(T), cultureInfo));
        }
Example #5
0
        public static PrintingConfig <TOwner> TrimmedToLength <TOwner>(this PropertyPrintingConfig <TOwner, string> propertyPrintingConfig,
                                                                       int maxLength)
        {
            var parentConfig = ((IPropertyPrintingConfig <TOwner, string>)propertyPrintingConfig).ParentConfig;

            return(parentConfig.ChangeStringMaxLength(maxLength));
        }
Example #6
0
 public static PrintingConfig <TOwner> TrimToLength <TOwner>(this PropertyPrintingConfig <TOwner, string> config, int length)
 {
     if (length < 0)
     {
         throw new ArgumentException("Length must be positive number");
     }
     return(config.Using(a => a.Substring(0, a.Length > length ? length : a.Length)));
 }
        public static PrintingConfig <TOwner> SetMaxLength <TOwner>(
            this PropertyPrintingConfig <TOwner, string> propConfig, int maxLen)
        {
            var propertyConfig = ((IPropertyPrintingConfig <TOwner, string>)propConfig).ParentConfig;

            propertyConfig.SetMaxLength(maxLen);
            return(propertyConfig);
        }
Example #8
0
        public static PrintingConfig <TOwner> Using <TOwner>(this PropertyPrintingConfig <TOwner, int> config,
                                                             CultureInfo cultureInfo)
        {
            var parent = (config as IPropertyPrintingConfig <TOwner>).ParentConfig;

            ((IPrintingConfig)parent).CultureLookup[typeof(int)] = cultureInfo;
            return(parent);
        }
Example #9
0
        public static PrintingConfig <TOwner> TrimmedToLength <TOwner>(this PropertyPrintingConfig <TOwner, string> propConfig, int maxLen)
        {
            var interfacedPropConfig = (IPropertyPrintingConfig <TOwner, string>)propConfig;

            interfacedPropConfig.SpecialPrintingFunctionsForMembers[interfacedPropConfig.Member] =
                o => ((string)o).Substring(0, ((string)o).Length < maxLen ? ((string)o).Length : maxLen);
            return(((IPropertyPrintingConfig <TOwner, string>)propConfig).ParentConfig);
        }
Example #10
0
        public static PrintingConfig <TOwner> Using <TOwner, TProp>(this PropertyPrintingConfig <TOwner, TProp> propConfig,
                                                                    CultureInfo culture) where TProp : IFormattable
        {
            var interfacedPropConfig = (IPropertyPrintingConfig <TOwner, TProp>)propConfig;

            interfacedPropConfig.SpecialPrintingFunctionsForTypes[typeof(TProp)] = o => ((TProp)o).ToString("", culture);
            return(interfacedPropConfig.ParentConfig);
        }
        public static PrintingConfig <TOwner> SetFormat <TOwner>(
            this PropertyPrintingConfig <TOwner, int> config, CultureInfo cultureInfo)
        {
            var parent = (config as IPropertyPrintingConfig <TOwner>).ParentConfig as IPrintingConfig <TOwner>;

            parent.DigitTypeToCulture[typeof(int)] = cultureInfo;
            return((config as IPropertyPrintingConfig <TOwner>).ParentConfig);
        }
Example #12
0
 public static PrintingConfig <TOwner> Trim <TOwner>(
     this PropertyPrintingConfig <TOwner, string> propConfig, int maxLength)
 {
     return(propConfig.Using(str =>
                             str.Length > maxLength
             ? str.Substring(0, maxLength)
             : str));
 }
Example #13
0
        public static PrintingConfig <TOwner> TrimmedToLength <TOwner>(this PropertyPrintingConfig <TOwner, string> propertyConfig, int maxLen)
        {
            var printingConfig = ((IPropertyPrintingConfig <TOwner, string>)propertyConfig).ParentConfig;
            var property       = ((IPropertyPrintingConfig <TOwner, string>)propertyConfig).PropertyInfo;

            ((IPrintingConfig <TOwner>)printingConfig).PropertyTrimmers[property] = maxLen;
            return(printingConfig);
        }
        public static PrintingConfig <TOwner> TrimmedToLength <TOwner>(
            this PropertyPrintingConfig <TOwner, string> propConfig, int maxLen)
        {
            var printingConfig = ((IPropertyPrintingConfig <TOwner, string>)propConfig).ParentConfig;

            printingConfig.TypeConverters[typeof(string)] =
                x => (x as string)?.Substring(0, Math.Min(((string)x).Length, maxLen));
            return(printingConfig);
        }
        public static PrintingConfig <TOwner> TrimmedToLength <TOwner>(this PropertyPrintingConfig <TOwner, string> propConfig, int maxLen)
        {
            Func <string, string> trim =
                str => (maxLen > str.Length) ? str : str.Substring(0, maxLen);
            var iPropConfig = (IPropertyPrintingConfig <TOwner, string>)propConfig;

            iPropConfig.ParentConfig.AddSerializationForProperty(iPropConfig.MemberName, trim, iPropConfig.DeclaringType);
            return(iPropConfig.ParentConfig);
        }
        public static PrintingConfig <TOwner> TrimmedToLength <TOwner>(
            this PropertyPrintingConfig <TOwner, string> propConfig, int maxLen)
        {
            ((IPrintingConfig <TOwner>)((IPropertyPrintingConfig <TOwner, string>)propConfig).ParentConfig)
            .PrintingConfigData
            .StringPropNamesTrimming[((IPropertyPrintingConfig <TOwner, string>)propConfig).MemberInfo] = maxLen;

            return(((IPropertyPrintingConfig <TOwner, string>)propConfig).ParentConfig);
        }
 public static PrintingConfig <TOwner> TrimmedToLength <TOwner>(this PropertyPrintingConfig <TOwner, string> propConfig, int maxLen)
 {
     propConfig.Using(s =>
     {
         var length = Math.Min(s.Length, Math.Max(maxLen, 0));
         return(s.Substring(0, length));
     });
     return(((IPropertyPrintingConfig <TOwner, string>)propConfig).ParentConfig);
 }
        public static PrintingConfig <TOwner> Using <TOwner, TPropType>(
            this PropertyPrintingConfig <TOwner, TPropType> propConfig, CultureInfo culture)
            where TPropType : IFormattable
        {
            var printingConfig = ((IPropertyPrintingConfig <TOwner, TPropType>)propConfig).ParentConfig;

            printingConfig.SetCulture <TPropType>(culture);
            return(printingConfig);
        }
        public static PrintingConfig <TOwner> Cut <TOwner>(
            this PropertyPrintingConfig <TOwner, string> config, int amount)
        {
            var parent       = (config as IPropertyPrintingConfig <TOwner>).ParentConfig as IPrintingConfig <TOwner>;
            var propertyInfo = (config as IPropertyPrintingConfig <TOwner>).ConfiguredProperty;

            parent.PropertyToLength[propertyInfo] = amount;

            return((config as IPropertyPrintingConfig <TOwner>).ParentConfig);
        }
Example #20
0
        public static PrintingConfig <TOwner> CutToLength <TOwner>(this PropertyPrintingConfig <TOwner, string> config,
                                                                   int length)
        {
            var cut            = new Func <string, string>(s => s.Substring(0, Math.Min(s.Length, length)));
            var property       = (config as IPropertyPrintingConfig <TOwner, string>).Property;
            var printingConfig = (config as IPropertyPrintingConfig <TOwner, string>).PrintingConfig;

            printingConfig.PropertyToCut.Add(property, cut);
            return(printingConfig);
        }
        public static PrintingConfig <TOwner> TrimmedToLength <TOwner>(this PropertyPrintingConfig <TOwner, string> propConfig, int maxLen)
        {
            var parentConfig = ((IPropertyPrintingConfig <TOwner, string>)propConfig).ParentConfig;

            if (((IPropertyPrintingConfig <TOwner, string>)propConfig).MemberSelector.Body is MemberExpression memberExpression)
            {
                ((IPrintingConfig)parentConfig).PropertyStringsLength[memberExpression.Member] = maxLen;
            }
            return(((IPropertyPrintingConfig <TOwner, string>)propConfig).ParentConfig);
        }
        public static PrintingConfig <TOwner> Using <TOwner, TPropType>(
            this PropertyPrintingConfig <TOwner, TPropType> config,
            CultureInfo cultureInfo)
        {
            var parentConfig = ((IPropertyPrintingConfig <TOwner, TPropType>)config)
                               .ParentConfig;

            parentConfig.typeCultureInfo[typeof(TPropType)] = cultureInfo;
            return(parentConfig);
        }
Example #23
0
        private static PrintingConfig <TOwner> AddCulture <TOwner, TNumber>(
            PropertyPrintingConfig <TOwner, TNumber> propConfig,
            CultureInfo culture)
        {
            var propertyConfig = (IPropertyPrintingConfig <TOwner, TNumber>)propConfig;
            var parentConfig   = propertyConfig.ParentConfig;
            var printingConfig = (IPrintingConfig)parentConfig;

            printingConfig.CultureForNumber[typeof(TNumber)] = culture;
            return(parentConfig);
        }
        public static PrintingConfig <TOwner> Using <TOwner>(
            this PropertyPrintingConfig <TOwner, float> config, CultureInfo cultureInfo)
        {
            var printingConfig = ((IPropertyPrintingConfig <TOwner, float>)config)
                                 .PrintingConfig;

            printingConfig = PrintingConfig <TOwner> .SetTypeSerializations(
                printingConfig, typeof(double), o => ((float)o).ToString(cultureInfo));

            return(printingConfig);
        }
        public static PrintingConfig <TOwner> CutToLength <TOwner>(
            this PropertyPrintingConfig <TOwner, string> config, int maxLen)
        {
            var printingConfig = ((IPropertyPrintingConfig <TOwner, string>)config)
                                 .PrintingConfig;

            printingConfig = PrintingConfig <TOwner> .SetPropSerializations(
                printingConfig, config.PropertyName, s => ((string)s).Substring(0, Math.Min(((string)s).Length, maxLen)));

            return(printingConfig);
        }
        public static PrintingConfig <TOwner> Trim <TOwner>(this PropertyPrintingConfig <TOwner, string> inner,
                                                            int size)
        {
            if (size <= 0)
            {
                throw new ArgumentException("size must be bigger then 0");
            }
            var printingConfig = ((IPropertyPrintingConfig <TOwner>)inner).PrintingConfig;

            printingConfig.StringTrim = size;
            return(printingConfig);
        }
        public static PrintingConfig <TOwner> TrimmedToLength <TOwner>(
            this PropertyPrintingConfig <TOwner, string> config,
            int length)
        {
            var propertySelector = ((IPropertyPrintingConfig <TOwner, string>)config)
                                   .PropertySelector;
            var propertyInfo = (PropertyInfo)((MemberExpression)propertySelector.Body).Member;

            var parentConfig = ((IPropertyPrintingConfig <TOwner, string>)config).ParentConfig;

            parentConfig.trimmedProperties[propertyInfo] = length;

            return(parentConfig);
        }
        public static PrintingConfig <TOwner> Trim <TOwner>
            (this PropertyPrintingConfig <TOwner, string> printingConfig, int lenght)
        {
            if (lenght <= 0)
            {
                throw new ArgumentException("Length should be positive");
            }

            var config = ((IPropertyPrintingConfig <TOwner>)printingConfig).PrintingConfig;

            ((IPrintingConfig)config).SetStringPropertiesLenght(lenght);

            return(config);
        }
Example #29
0
        public PropertyPrintingConfig <TOwner, TProp> Printing <TProp>()
        {
            var typePrintingConfig = new PropertyPrintingConfig <TOwner, TProp>(this);

            if (typeof(TProp) == typeof(string))
            {
                AddCommonStringPrintingConfig((IPropertyPrintingConfig <string>)typePrintingConfig);
            }
            else
            {
                typesPrintingConfigs[typeof(TProp)] = ExtractPrintingFunction(typePrintingConfig);
            }
            return(typePrintingConfig);
        }
Example #30
0
        public static PrintingConfig <TOwner> TrimmedToLength <TOwner>(this PropertyPrintingConfig <TOwner, string> propConfig, int maxLen)
        {
            Func <string, string> trimFunc = s => s.Substring(0, Math.Min(s.Length, maxLen));

            if (!((IPropertyPrintingConfig <TOwner, string>)propConfig).ParentConfig.configuration.TrimmingProperties.ContainsKey(typeof(TOwner)))
            {
                ((IPropertyPrintingConfig <TOwner, string>)propConfig).ParentConfig.configuration.TrimmingProperties[typeof(TOwner)] = new Dictionary <string, Delegate>();
            }

            ((IPropertyPrintingConfig <TOwner, string>)propConfig)
            .ParentConfig.configuration.TrimmingProperties[typeof(TOwner)][propConfig.propertyName] = trimFunc;

            return(((IPropertyPrintingConfig <TOwner, string>)propConfig).ParentConfig);
        }