示例#1
0
        public void ShouldAssignAnyToNative()
        {
            SinTDType any      = SinTDInstance.GetSinTDType("any");
            var       anyValue = 1;

            Assert.AreEqual(anyValue, any.AssignValuesToNativeType(anyValue, anyValue.GetType()));
        }
示例#2
0
 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);
     }
 }
示例#3
0
        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));
        }
示例#4
0
        public void ShouldAssignStringToNativeString()
        {
            SinTDType s = SinTDInstance.GetSinTDType("string");

            Assert.AreEqual("Hello World", s.AssignValuesToNativeType("Hello World", typeof(string)));
        }
示例#5
0
        public void ShouldAssignBooleanToNativeBool()
        {
            SinTDType b = SinTDInstance.GetSinTDType("boolean");

            Assert.AreEqual(true, b.AssignValuesToNativeType(true, typeof(bool)));
        }
示例#6
0
        public void ShouldAssignDoubleToNativeDouble()
        {
            SinTDType d = SinTDInstance.GetSinTDType("double");

            Assert.AreEqual(1.0, d.AssignValuesToNativeType(1.0, typeof(double)));
        }
示例#7
0
        public void ShouldAssignFloatToNativeFloat()
        {
            SinTDType f = SinTDInstance.GetSinTDType("float");

            Assert.AreEqual(1.0f, f.AssignValuesToNativeType(1.0, typeof(float)));
        }
示例#8
0
        public void ShouldAssignU64ToNativeUlong()
        {
            SinTDType u64 = SinTDInstance.GetSinTDType("u64");

            Assert.AreEqual((ulong)1, u64.AssignValuesToNativeType(1, typeof(ulong)));
        }
示例#9
0
        public void ShouldAssignInt64ToNativeLong()
        {
            SinTDType i64 = SinTDInstance.GetSinTDType("i64");

            Assert.AreEqual((long)1, i64.AssignValuesToNativeType(1, typeof(long)));
        }
示例#10
0
        public void ShouldAssignUInt32ToNativeUInt()
        {
            SinTDType u32 = SinTDInstance.GetSinTDType("u32");

            Assert.AreEqual(1, u32.AssignValuesToNativeType(1, typeof(uint)));
        }
示例#11
0
        public void ShouldAssignInt32ToNativeInt()
        {
            SinTDType i32 = SinTDInstance.GetSinTDType("i32");

            Assert.AreEqual(1, i32.AssignValuesToNativeType(1, typeof(int)));
        }
示例#12
0
        public void ShouldAssignUInt16ValueToNativeUshort()
        {
            SinTDType u16 = SinTDInstance.GetSinTDType("u16");

            Assert.AreEqual(1, u16.AssignValuesToNativeType(1, typeof(ushort)));
        }
示例#13
0
        public void ShouldAssingI16toNativeShort()
        {
            SinTDType i16 = SinTDInstance.GetSinTDType("i16");

            Assert.AreEqual((short)1, i16.AssignValuesToNativeType(1, typeof(short)));
        }