コード例 #1
0
        public static PrintingConfig <TOwner> CutPrefix <TOwner>(this PropertySerializingConfig <TOwner, string> config,
                                                                 int prefixLen)
        {
            var prop = (config as IPropertySerializingConfig <TOwner>).PropertyInfo;

            ((config as IPropertySerializingConfig <TOwner>).ParentConfig
             as IPrintingConfig <TOwner>).MaxLengthOfStringProperty[prop] = prefixLen;
            return((config as IPropertySerializingConfig <TOwner>).ParentConfig);
        }
コード例 #2
0
 public static PrintingConfig <TOwner> TakeOnly <TOwner>(this PropertySerializingConfig <TOwner, string> config,
                                                         int numberChar)
 {
     return(config.Using(str =>
     {
         if (str == null)
         {
             return "<null>";
         }
         return str.Length < numberChar ? str : str.Substring(0, numberChar);
     }));
 }
コード例 #3
0
        public static PrintingConfig <TOwner> TrimmingToLength <TOwner>(this PropertySerializingConfig <TOwner, string> config,
                                                                        int length)
        {
            var propertyInfo = (config as IPropertySerializingConfig <TOwner>).UsedPropertyInfo;
            var parent       = (config as IPropertySerializingConfig <TOwner>).ParentConfig as IPrintingConfig <TOwner>;

            if (propertyInfo is null)
            {
                UpdateMethod(parent.SerializingMethods, typeof(string), s => new string(s.Take(length).ToArray()));
            }
            else
            {
                UpdateMethod(parent.PropertySerializingMethods, propertyInfo, s => new string(s.Take(length).ToArray()));
            }

            return((config as IPropertySerializingConfig <TOwner>).ParentConfig);
        }
コード例 #4
0
 public static PrintingConfig <TOwner> Using <TOwner>(
     this PropertySerializingConfig <TOwner, double> propertySerializingConfig, CultureInfo cultureInfo)
 {
     return(propertySerializingConfig.Using(d => d.ToString(cultureInfo)));
 }