Esempio n. 1
0
 // Customized Deserialization for Card
 // The class Neunity.Adapter.Op manages type conversation for different platforms
 public static Card Bytes2Card(byte[] data) => new Card
 {
     type       = Op.Bytes2BigInt(SD.DesegWithIdFromSeg(data, 0)),
     lvls       = SD.DesegWithIdFromSeg(data, 1),
     birthBlock = Op.Bytes2BigInt(SD.DesegWithIdFromSeg(data, 2)),
     name       = Op.Bytes2String(SD.DesegWithIdFromSeg(data, 3)),
 };
Esempio n. 2
0
        public static War ByteArrayToWar(byte[] data)
        {
            War war = new War();

            war.id          = Op.Bytes2String(SD.DesegWithIdFromSeg(data, 0));
            war.regEndBlock = Op.Bytes2BigInt(SD.DesegWithIdFromSeg(data, 1));
            BigInteger height = Blockchain.GetHeight();

            war.regLeftBlocks = war.regEndBlock - height;
            return(war);
        }
Esempio n. 3
0
        public void TestDataDesegWithID()
        {
            //public static byte[] tableThree = { 5, 1, 2, 3, 4, 5, 2, 12, 2, 1, 0 };
            byte[] b1 = SD.DesegWithIdFromTable(tableThree, 0);
            byte[] b2 = SD.DesegWithIdFromTable(tableThree, 1);
            byte[] b3 = SD.DesegWithIdFromTable(tableThree, 2);

            byte[] seg = SD.Seg(tableThree);
            byte[] b4  = SD.DesegWithIdFromSeg(seg, 1);

            Assert.AreEqual(b1, new byte[] { 1, 2, 3, 4, 5 });
            Assert.AreEqual(b2, new byte[] { 12, 2 });
            Assert.AreEqual(b3, new byte[] { 0 });
            Assert.AreEqual(b4, new byte[] { 12, 2 });
        }
Esempio n. 4
0
 public static Student Bytes2Student(byte[] data) => new Student
 {
     id      = Op.Bytes2BigInt(SD.DesegWithIdFromSeg(data, 0)),
     name    = Op.Bytes2String(SD.DesegWithIdFromSeg(data, 1)),
     balance = Op.Bytes2BigInt(SD.DesegWithIdFromSeg(data, 2))
 };