Exemple #1
0
        public override string ToString()
        {
            string fieldValue = string.Empty;

            //判断类型
            if (this._value.GetType() == typeof(string))
            {
                fieldValue = this._value.ToString();
            }
            if (this._value.GetType() == typeof(bool))
            {
                fieldValue = CommandUtil.GetBooleanString(Convert.ToBoolean(this._value));
            }

            //是否是固定宽度
            if (_isFixed)
            {
                if (fieldValue.Length < FixedLength)
                {
                    fieldValue = fieldValue.PadRight(FixedLength, ' ');
                }
                else
                {
                    throw new ParameterException($"fixed field value {fieldValue} length is more then fixed length {FixedLength}");
                }
            }

            return($"{this.ID ?? string.Empty}{fieldValue}{this.Split ?? string.Empty}");
        }