コード例 #1
0
        protected override object GetPropertyValue(PropertyInfo prop, TelepayFieldAttribute attr)
        {
            switch (prop.Name)
            {
            case "TextCode":
                return(((int)TextCode).ToString("d3"));

            case "TransferCode":
                return(TransferCode.ToString());

            default:
                return(base.GetPropertyValue(prop, attr));
            }
        }
コード例 #2
0
        protected virtual object GetPropertyValue(PropertyInfo prop, TelepayFieldAttribute attr)
        {
            var value = prop.GetValue(this, null) ?? "";

            var empty = attr.Length.Value - value.ToString().Length;

            switch (attr.Type)
            {
            case FieldType.Alpha:
                value += EmptyString(empty);
                break;

            case FieldType.Alphanumeric:
                value += EmptyNum(empty);
                break;

            case FieldType.Numeric:
                long val = 0;
                try
                {
                    val = Convert.ToInt64(value);
                }
                catch
                {
                }
                //int.TryParse(value.ToString(), out val);
                value = val.ToString("d" + attr.Length);
                break;

            default:
                value = value.ToString();
                break;
            }

            if (value.ToString().Length > attr.Length)
            {
                throw new ArgumentException(string.Concat("The values of the ", prop.ReflectedType.Name, ".", prop.Name,
                                                          " property is too long."));
            }
            return(value);
        }
コード例 #3
0
        public static string GetTextCode(PropertyInfo prop, TelepayFieldAttribute attr, object data)
        {
            TextCode code = (TextCode)prop.GetValue(data, null);

            return(((int)code).ToString("d3"));
        }