Esempio n. 1
0
 private static void BinaryOp(Func <SqlType, Func <ISqlValue, ISqlValue, ISqlValue> > selector, bool value1, bool value2,
                              bool expected)
 {
     OperatorsUtil.Binary(PrimitiveTypes.Boolean(), selector, value1, value2, expected);
 }
 public static void IsCodePrimitive(SqlTypeCode typeCode, bool expected)
 {
     Assert.Equal(expected, PrimitiveTypes.IsPrimitive(typeCode));
 }
 public static void GetInvalidNumeric(SqlTypeCode typeCode)
 {
     Assert.Throws <ArgumentException>(() => PrimitiveTypes.Numeric(typeCode, 20, 10));
 }
 public static void IsStringPrimitive(string name, bool expected)
 {
     Assert.Equal(expected, PrimitiveTypes.IsPrimitive(name));
 }
 public static void GetInvalidBoolean()
 {
     Assert.Throws <ArgumentException>(() => PrimitiveTypes.Boolean(SqlTypeCode.Blob));
 }
Esempio n. 6
0
 public static bool IsPrimitiveType(SqlTypeCode typeCode)
 {
     return(PrimitiveTypes.IsPrimitive(typeCode));
 }
 private static void BinaryOp(Func <SqlType, Func <ISqlValue, ISqlValue, SqlBoolean> > selector, object value1, object value2, bool expected)
 {
     OperatorsUtil.Binary(PrimitiveTypes.Double(), selector, value1, value2, expected);
 }
Esempio n. 8
0
        public static SqlType Deserialize(BinaryReader reader, ITypeResolver resolver)
        {
            var typeCode = (SqlTypeCode)reader.ReadByte();

            if (BooleanType.IsBooleanType(typeCode))
            {
                return(PrimitiveTypes.Boolean(typeCode));
            }
            if (IntervalType.IsIntervalType(typeCode))
            {
                return(PrimitiveTypes.Interval(typeCode));
            }
            if (DateType.IsDateType(typeCode))
            {
                return(PrimitiveTypes.DateTime(typeCode));
            }

            if (StringType.IsStringType(typeCode))
            {
                var maxSize = reader.ReadInt32();

                CultureInfo locale    = null;
                var         hasLocale = reader.ReadByte() == 1;
                if (hasLocale)
                {
                    var name = reader.ReadString();
                    locale = new CultureInfo(name);
                }

                // TODO: Get the encoding from the serialization...
                return(PrimitiveTypes.String(typeCode, maxSize, Encoding.Unicode, locale));
            }

            if (NumericType.IsNumericType(typeCode))
            {
                var size  = reader.ReadInt32();
                var scale = reader.ReadInt32();

                return(PrimitiveTypes.Numeric(typeCode, size, scale));
            }

            if (BinaryType.IsBinaryType(typeCode))
            {
                var size = reader.ReadInt32();
                return(PrimitiveTypes.Binary(typeCode, size));
            }

            if (typeCode == SqlTypeCode.Type)
            {
                // TODO:
            }

            if (typeCode == SqlTypeCode.QueryPlan)
            {
                return(new QueryType());
            }

            if (typeCode == SqlTypeCode.Array)
            {
                var size = reader.ReadInt32();
                return(new ArrayType(size));
            }

            if (typeCode == SqlTypeCode.Null)
            {
                return(PrimitiveTypes.Null());
            }

            throw new NotSupportedException();
        }