/// <summary> /// Returns the scalar type for the strings, decimals, uris, etc... /// </summary> /// <param name="type"></param> /// <param name="scalarType"></param> /// <returns></returns> public static bool TryGetBuiltInScalarType( Type type, [NotNullWhen(true)] out ScalarType?scalarType ) { if (type == typeof(string)) { scalarType = new StringType(); } else if (type == typeof(decimal)) { scalarType = new DecimalType(); } else if (type == typeof(int)) { scalarType = new IntType(); } else if (type == typeof(bool)) { scalarType = new BooleanType(); } else if (type == typeof(float)) { scalarType = new FloatType(); } else if (type == typeof(Guid)) { scalarType = new UuidType(); } else if (type == typeof(DateTime)) { scalarType = new DateTimeType(); } else if (type == typeof(byte)) { scalarType = new ByteType(); } else if (type == typeof(Uri)) { scalarType = new UrlType(); } else if (type == typeof(long)) { scalarType = new LongType(); } else if (type == typeof(short)) { scalarType = new ShortType(); } else { scalarType = null; } return(scalarType is object); }
private long ReturnWeight(string Weight) { object obj2 = null; for (long i = 1L; i <= Strings.Len(Weight); i += 1L) { obj2 = ObjectType.AddObj(obj2, Strings.Asc(Strings.Mid(Weight, (int)i, 1))); } return(LongType.FromObject(obj2)); }
private static bool CanAppend(FluentEntityProperty <EntityColumnAttribute> property, object entity) { var id = 0L; if (property.Attribute.IsKey) { id = LongType.FromObject(property.Property.GetValue(entity) ?? 0L); } return(!property.Attribute.IsKey || id != 0L); }
public void Implicit_SByte_Cast() { // arrange sbyte expected = 100; // act LongType actual = expected; // assert Assert.AreEqual(expected, (sbyte)actual); }
public void Implicit_Int64_Cast() { // arrange long expected = 100; // act LongType actual = expected; // assert Assert.AreEqual(expected, (long)actual); }
public void Implicit_Int16_Cast() { // arrange short expected = 100; // act LongType actual = expected; // assert Assert.AreEqual(expected, (short)actual); }
public void Implicit_Int32_Cast() { // arrange int expected = 100; // act LongType actual = expected; // assert Assert.AreEqual(expected, (int)actual); }
public void ParseWithNumberStylesShouldReturnOptionLongNoneWhenStringIsNotExpectedHexNumber() { // Arrange var s = "1.0"; Option <long> expected = None; // Act var result = LongType.Parse(s, NumberStyles.HexNumber); // Assert result.Should().Be(expected); }
public void ParseWithNumberStylesShouldReturnOptionLongNone() { // Arrange var s = "not a long"; Option <long> expected = None; // Act var result = LongType.Parse(s, NumberStyles.Integer); // Assert result.Should().Be(expected); }
public void ParseWithNumberStylesShouldReturnOptionLongSome() { // Arrange var s = "1"; Option <long> expected = Some(1L); // Act var result = LongType.Parse(s, NumberStyles.Number); // Assert result.Should().Be(expected); }
public void ParseShouldReturnOptionLongNone() { // Arrange var s = "not a long"; Option <long> expected = None; // Act var result = LongType.Parse(s); // Assert result.Should().Be(expected); }
public void Operator_NotEqualTo() { // arrange long value = 100L; LongType type = value; // act bool actual = type != value; // assert Assert.IsFalse(actual); }
public void Implicit_ByteArray_Cast() { // arrange byte[] expected = new byte[] { 0, 0, 0, 0, 0, 0, 64, 128 }; // act LongType actualType = expected; byte[] actual = actualType; // assert Assert.IsTrue(expected.SequenceEqual(actual)); }
public void ParseWithNumberStylesAndFormatProviderShouldReturnOptionLongNone() { // Arrange var s = "p1$234"; IFormatProvider formatProvider = new NumberFormatInfo() { PositiveSign = "p" }; Option <long> expected = None; // Act var result = LongType.Parse(s, NumberStyles.Integer, formatProvider); // Assert result.Should().Be(expected); }
private void Populate() { IntegerType c1 = new IntegerType("id", "id"); Border b1 = c1.Border; stackPanel.Children.Add(b1); StringType c2 = new StringType("First Name", "First Name"); Border b2 = c2.Border; stackPanel.Children.Add(b2); StringType c3 = new StringType("Last Name", "Last Name"); Border b3 = c3.Border; stackPanel.Children.Add(b3); RadioType c4 = new RadioType("Gender", "Male", "Female"); Border b4 = c4.Border; stackPanel.Children.Add(b4); LongType c5 = new LongType("Phone No.", "Phone No"); Border b5 = c5.Border; stackPanel.Children.Add(b5); DateType c9 = new DateType("Date", System.DateTime.Now); Border b9 = c9.Border; stackPanel.Children.Add(b9); FloatType c6 = new FloatType("Salary", "Salary"); Border b6 = c6.Border; stackPanel.Children.Add(b6); IntegerType c7 = new IntegerType("Roll no", "Roll No"); Border b7 = c7.Border; stackPanel.Children.Add(b7); StringType c8 = new StringType("Address", "Address"); Border b8 = c8.Border; stackPanel.Children.Add(b8); }
public void ParseWithFormatProviderShouldReturnOptionLongSome() { // Arrange var s = "p1234"; IFormatProvider formatProvider = new NumberFormatInfo() { PositiveSign = "p" }; Option <long> expected = Some(1234L); // Act var result = LongType.Parse(s, formatProvider); // Assert result.Should().Be(expected); }
/// <summary> /// Tipos básicos não possuem transformações especiais. /// </summary> /// <param name="valueTypes"></param> /// <returns></returns> private static TypeBase GetTypeFromValue(TypeRef valueTypes) { if (valueTypes == null) { return(null); } switch (valueTypes.AsString().ToLower()) { case "byte[]": case "string": return(StringType.Create()); case "int": return(IntegerType.Create()); case "int?": return(IntegerType.CreateNullable()); case "datetime": return(DateType.Create()); case "datetime?": return(DateType.CreateNullable()); case "long": return(LongType.Create()); case "long?": return(LongType.CreateNullable()); case "bool": return(BoolType.Create()); case "bool?": return(BoolType.CreateNullable()); default: throw new ArgumentOutOfRangeException("valueTypes", "Não foi possível determinar o tipo da propriedade!"); } }
public static String Oct(Object Number) { if (Number == null) { throw new ArgumentNullException("Number"); } switch (ObjectType.GetTypeCode(Number)) { case TypeCode.Byte: return(Oct(ByteType.FromObject(Number))); case TypeCode.Int16: return(Oct(ShortType.FromObject(Number))); case TypeCode.Boolean: case TypeCode.Char: case TypeCode.SByte: case TypeCode.UInt16: case TypeCode.Int32: return(Oct(IntegerType.FromObject(Number))); case TypeCode.Int64: return(Oct(LongType.FromObject(Number))); case TypeCode.UInt32: case TypeCode.UInt64: case TypeCode.Single: case TypeCode.Double: case TypeCode.Decimal: return(Oct(LongType.FromObject(Number))); case TypeCode.String: return(Oct(LongType.FromString (StringType.FromObject(Number)))); } throw new ArgumentException(S._("VB_InvalidNumber"), "Number"); }
public void FromString_NotSupported(string value, long expected) { Assert.Throws <InvalidCastException>(() => LongType.FromString(value)); }
public PropertyAnonymousInnerClass(ProjectDBUtil outerInstance) { this.outerInstance = outerInstance; lType = new LongType(); }
public static void AddLong(this CompositeType type, LongType value) { type.Add(value); }
public void FromObject_ThrowsOverflowException(object value) { Assert.Throws <OverflowException>(() => LongType.FromObject(value)); }
public void FromString_ThrowsOverflowException(string value) { Assert.Throws <OverflowException>(() => LongType.FromString(value)); }
public void FromString_ThrowsInvalidCastException(string value) { Assert.Throws <InvalidCastException>(() => LongType.FromString(value)); }
public void FromString(string value, long expected) { Assert.Equal(expected, LongType.FromString(value)); }
// Inner version of "Print" and "Write". private static void Print(File file, Object[] Output, CultureInfo culture, bool print) { NumberFormatInfo nfi = culture.NumberFormat; if (Output == null) { return; } bool first = true; foreach (Object obj in Output) { if (!first && !print) { file.Write(","); } else { first = false; } if (obj == null) { if (!print) { file.Write("#NULL#"); } continue; } if (obj is TabInfo) { file.Tab((TabInfo)obj); continue; } else if (obj is SpcInfo) { file.Space((SpcInfo)obj); continue; } else if (obj is char[]) { file.Write(new String((char[])obj)); continue; } else if (obj is ErrObject) { if (print) { file.Write(String.Format("Error {0}", ((ErrObject)obj).Number)); } else { file.Write(String.Format("#ERROR {0}#", ((ErrObject)obj).Number)); } continue; } switch (ObjectType.GetTypeCode(obj)) { case TypeCode.DBNull: { if (print) { file.Write("Null"); } else { file.Write("#NULL#"); } } break; case TypeCode.Boolean: { bool b = BooleanType.FromObject(obj); if (print) { file.Write(b.ToString(culture)); } else if (b) { file.Write("#TRUE#"); } else { file.Write("#FALSE#"); } } break; case TypeCode.Byte: { byte by = ByteType.FromObject(obj); file.Write(by.ToString(nfi)); } break; case TypeCode.Int16: { short s = ShortType.FromObject(obj); file.Write(s.ToString(nfi)); } break; case TypeCode.Int32: { int i = IntegerType.FromObject(obj); file.Write(i.ToString(nfi)); } break; case TypeCode.Int64: { long l = LongType.FromObject(obj); file.Write(l.ToString(nfi)); } break; case TypeCode.Single: { float f = SingleType.FromObject(obj, nfi); file.Write(f.ToString(nfi)); } break; case TypeCode.Double: { double d = DoubleType.FromObject(obj, nfi); file.Write(d.ToString(nfi)); } break; case TypeCode.Decimal: { Decimal dc = DecimalType.FromObject(obj, nfi); file.Write(dc.ToString(nfi)); } break; case TypeCode.DateTime: { DateTime dt = DateType.FromObject(obj); if (print) { file.Write(StringType.FromDate(dt) + " "); } else { String format; long dayTicks = dt.Ticks % TimeSpan.TicksPerDay; if (dt.Ticks == dayTicks) { format = "T"; } else if (dayTicks == 0) { format = "d"; } else { format = "F"; } file.Write(dt.ToString (format, culture.DateTimeFormat)); } } break; case TypeCode.String: { file.Write(StringType.FromObject(obj)); } break; default: { Utils.ThrowException(5); // ArgumentException. } break; } } }
public void FromObject_ThrowsInvalidCastException(object value) { Assert.Throws <InvalidCastException>(() => LongType.FromObject(value)); }
public void FromObject(object value, long expected) { Assert.Equal(expected, LongType.FromObject(value)); }
public void FromObject_NotSupported(object value, long expected) { Assert.Throws <InvalidCastException>(() => LongType.FromObject(value)); }