public void ShouldAssignAnyToNative() { SinTDType any = SinTDInstance.GetSinTDType("any"); var anyValue = 1; Assert.AreEqual(anyValue, any.AssignValuesToNativeType(anyValue, anyValue.GetType())); }
public T As <T>() { if (!CurrentValue.GetType().IsAssignableFrom(typeof(T)) && World.Instance.SinTd.ContainsType(Type.Name)) { SinTDType typeAsKtdType = World.Instance.SinTd.GetSinTDType(Type.Name); Type t = typeof(T); return((T)typeAsKtdType.AssignValuesToNativeType(Value, t)); } else { return((T)Value); } }
private object convertValueToAttributeType(object value) { if (value == null || value.GetType() == this.Type) { return(value); } if (World.Instance.SinTd != null && World.Instance.SinTd.ContainsType(this.Type.Name)) { SinTDType typeAsKtdType = World.Instance.SinTd.GetSinTDType(this.Type.Name); return(typeAsKtdType.AssignValuesToNativeType(value, this.Type)); } return(Convert.ChangeType(value, this.Type)); }
public void ShouldAssignStringToNativeString() { SinTDType s = SinTDInstance.GetSinTDType("string"); Assert.AreEqual("Hello World", s.AssignValuesToNativeType("Hello World", typeof(string))); }
public void ShouldAssignBooleanToNativeBool() { SinTDType b = SinTDInstance.GetSinTDType("boolean"); Assert.AreEqual(true, b.AssignValuesToNativeType(true, typeof(bool))); }
public void ShouldAssignDoubleToNativeDouble() { SinTDType d = SinTDInstance.GetSinTDType("double"); Assert.AreEqual(1.0, d.AssignValuesToNativeType(1.0, typeof(double))); }
public void ShouldAssignFloatToNativeFloat() { SinTDType f = SinTDInstance.GetSinTDType("float"); Assert.AreEqual(1.0f, f.AssignValuesToNativeType(1.0, typeof(float))); }
public void ShouldAssignU64ToNativeUlong() { SinTDType u64 = SinTDInstance.GetSinTDType("u64"); Assert.AreEqual((ulong)1, u64.AssignValuesToNativeType(1, typeof(ulong))); }
public void ShouldAssignInt64ToNativeLong() { SinTDType i64 = SinTDInstance.GetSinTDType("i64"); Assert.AreEqual((long)1, i64.AssignValuesToNativeType(1, typeof(long))); }
public void ShouldAssignUInt32ToNativeUInt() { SinTDType u32 = SinTDInstance.GetSinTDType("u32"); Assert.AreEqual(1, u32.AssignValuesToNativeType(1, typeof(uint))); }
public void ShouldAssignInt32ToNativeInt() { SinTDType i32 = SinTDInstance.GetSinTDType("i32"); Assert.AreEqual(1, i32.AssignValuesToNativeType(1, typeof(int))); }
public void ShouldAssignUInt16ValueToNativeUshort() { SinTDType u16 = SinTDInstance.GetSinTDType("u16"); Assert.AreEqual(1, u16.AssignValuesToNativeType(1, typeof(ushort))); }
public void ShouldAssingI16toNativeShort() { SinTDType i16 = SinTDInstance.GetSinTDType("i16"); Assert.AreEqual((short)1, i16.AssignValuesToNativeType(1, typeof(short))); }