Ejemplo n.º 1
0
        public static IType Create(DataType oDataType, IConvertible oIConvertible, IFormatProvider oIFormatProvider)
        {
            IType oIType;

            switch (oDataType.m_oKind)
            {
            case Kind.Boolean:
                oIType = new BooleanType(oIConvertible, oIFormatProvider);
                break;

            case Kind.Currency:
                oIType = new CurrencyType(oIConvertible, oIFormatProvider);
                break;

            case Kind.Date:
                oIType = new DateType(oIConvertible, oIFormatProvider);
                break;

            case Kind.DateTime:
                oIType = new DateTimeType(oIConvertible, oIFormatProvider);
                break;

            case Kind.Decimal:
                oIType = new DecimalType(oIConvertible, oIFormatProvider);
                break;

            case Kind.Double:
                oIType = new DoubleType(oIConvertible, oIFormatProvider);
                break;

            case Kind.Int16:
                oIType = new Int16Type(oIConvertible, oIFormatProvider);
                break;

            case Kind.Int32:
                oIType = new Int32Type(oIConvertible, oIFormatProvider);
                break;

            case Kind.Int64:
                oIType = new Int64Type(oIConvertible, oIFormatProvider);
                break;

            case Kind.Single:
                oIType = new SingleType(oIConvertible, oIFormatProvider);
                break;

            case Kind.String:
                oIType = new StringType(oIConvertible, oIFormatProvider);
                break;

            case Kind.Text:
                oIType = new TextType(oIConvertible, oIFormatProvider);
                break;

            default:
                throw new ArgumentException(string.Format("Invalid type {0} specified", oDataType));
            }
            return(oIType);
        }
Ejemplo n.º 2
0
        public static IType Create(IConvertible oIConvertible, IFormatProvider oIFormatProvider)
        {
            IType oIType;

            switch (oIConvertible.GetTypeCode())
            {
            case TypeCode.Boolean:
                oIType = new BooleanType(oIConvertible, oIFormatProvider);
                break;

            case TypeCode.Byte:
                oIType = new Int16Type(oIConvertible, oIFormatProvider);
                break;

            case TypeCode.Char:
                oIType = new StringType(oIConvertible, oIFormatProvider);
                break;

            case TypeCode.DateTime:
                oIType = new DateTimeType(oIConvertible, oIFormatProvider);
                break;

            case TypeCode.DBNull:
                oIType = DataType.Empty(DataType.None);
                break;

            case TypeCode.Decimal:
                oIType = new DecimalType(oIConvertible, oIFormatProvider);
                break;

            case TypeCode.Double:
                oIType = new DoubleType(oIConvertible, oIFormatProvider);
                break;

            case TypeCode.Int16:
                oIType = new Int16Type(oIConvertible, oIFormatProvider);
                break;

            case TypeCode.Int32:
                oIType = new Int32Type(oIConvertible, oIFormatProvider);
                break;

            case TypeCode.Int64:
                oIType = new Int64Type(oIConvertible, oIFormatProvider);
                break;

            case TypeCode.Object:
                oIType = oIConvertible as IType ?? new StringType(oIConvertible, oIFormatProvider);
                break;

            case TypeCode.SByte:
                oIType = new Int16Type(oIConvertible, oIFormatProvider);
                break;

            case TypeCode.Single:
                oIType = new SingleType(oIConvertible, oIFormatProvider);
                break;

            case TypeCode.String:
                oIType = new StringType(oIConvertible, oIFormatProvider);
                break;

            default:
                throw new ArgumentException(string.Format("Invalid value type {0} specified", oIConvertible.GetType()));
            }
            return(oIType);
        }