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); }
protected override object GetFieldValueFromString(FieldSettings <T> fieldSettings, string memberValue) { if (!string.IsNullOrEmpty(Quotes)) { memberValue = memberValue.Replace(Quotes, String.Empty); } return(base.GetFieldValueFromString(fieldSettings, memberValue)); }
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); }
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); }
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)); }
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); }