Exemple #1
0
        public void CharacterSaveTest()
        {
            HatCharacter chr = new HatCharacter();

            chr.CharacterID   = 1;
            chr.CharacterData = new byte[] { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
            chr.ParentUserID  = 0xfa;

            factory.Save(chr);

            BinaryFormatter frm = new BinaryFormatter( );

            using (MemoryStream mem = new MemoryStream( )) {
                frm.Serialize(mem, chr);

                mem.Seek(0, SeekOrigin.Begin);

                HatCharacter c = (HatCharacter)frm.Deserialize(mem);
            }
            HatCharacter getChr = factory.LookupFirst <HatCharacter>(new SelectByCodeCondition(1));

            Assert.AreEqual(chr.CharacterID, getChr.CharacterID);
            Assert.AreEqual(chr.CharacterData, getChr.CharacterData);
            Assert.AreEqual(chr.ParentUserID, getChr.ParentUserID);
        }
Exemple #2
0
        public void ParseData(byte[] data)
        {
            using (var mem = new MemoryStream(data)) {
                mem.Seek(0, SeekOrigin.Begin);
                using (var reader = new BinaryReader(mem)) {
                    character = new HatCharacter();

                    Int32 size = reader.ReadInt32();
                    character.CharacterId    = reader.ReadInt64();
                    character.CharacterValue = reader.ReadBytes(size - 8);
                }
            }
        }