示例#1
0
文件: Layout.cs 项目: sttt/FlatMapper
        protected Layout <T> WithMember(Expression <Func <T, object> > expression, Action <IFieldSettings> settings)
        {
            var fieldSettings = new FieldSettings <T>(expression);

            settings(fieldSettings);
            InnerFields.Add(fieldSettings);
            return(this);
        }
示例#2
0
 protected override object GetFieldValueFromString(FieldSettings <T> fieldSettings, string memberValue)
 {
     if (!string.IsNullOrEmpty(Quotes))
     {
         memberValue = memberValue.Replace(Quotes, String.Empty);
     }
     return(base.GetFieldValueFromString(fieldSettings, memberValue));
 }
示例#3
0
        protected Layout <T> WithMember <TMember>(Expression <Func <T, TMember> > expression, Action <IFieldSettings <T, TMember> > settings)
        {
            var fieldSettings = new FieldSettings <T, TMember>(expression);

            settings(fieldSettings);
            fieldSettings.FieldValueConverter = fieldSettings.FieldValueConverter ?? new FieldValueConverter <TMember>();
            InnerFields.Add(fieldSettings);
            return(this);
        }
示例#4
0
            protected override string GetStringValueFromField(FieldSettings <T> field, object fieldValue)
            {
                var stringValue = base.GetStringValueFromField(field, fieldValue);

                if (!string.IsNullOrEmpty(Quotes))
                {
                    stringValue = string.Format("{0}{1}{0}", Quotes, stringValue);
                }
                return(stringValue);
            }
示例#5
0
文件: Layout.cs 项目: sttt/FlatMapper
        protected virtual object GetFieldValueFromString(FieldSettings <T> fieldSettings, string memberValue)
        {
            if (fieldSettings.IsNullable && memberValue.Equals(fieldSettings.NullValue))
            {
                return(null);
            }
            memberValue = fieldSettings.PadLeft
                            ? memberValue.TrimStart(new char[] { fieldSettings.PaddingChar })
                            : memberValue.TrimEnd(new char[] { fieldSettings.PaddingChar });

            //TODO: Execute here custom converters
            return(Convert.ChangeType(memberValue, fieldSettings.ConvertToType));
        }
示例#6
0
文件: Layout.cs 项目: sttt/FlatMapper
        protected virtual string GetStringValueFromField(FieldSettings <T> field, object fieldValue)
        {
            if (fieldValue == null)
            {
                return(field.NullValue);
            }
            string lineValue = fieldValue.ToString();

            if (lineValue.Length < field.Length)
            {
                lineValue = field.PadLeft
                                ? lineValue.PadLeft(field.Length, field.PaddingChar)
                                : lineValue.PadRight(field.Length, field.PaddingChar);
            }
            return(lineValue);
        }