Deserialize() public method

Serialized 된 정보를 Deserialize 를 수행해서 객체로 반환한다.
public Deserialize ( byte data ) : object
data byte serialized data to be deserialized.
return object
        public void Compress_BsonSerializer() {
            var serializer = new CompressSerializer<UserInfo>(new BsonSerializer<UserInfo>());

            var serializedUser = serializer.Serialize(user);
            var deserializedUser = serializer.Deserialize(serializedUser);

            Assert.AreEqual(user.FirstName, deserializedUser.FirstName);
            Assert.AreEqual(user.FavoriteMovies.Count, user.FavoriteMovies.Count);
        }
Example #2
0
        public void XmlSerialize_With_Encryption_Compress([Values(typeof(SharpBZip2Compressor),
                                                              typeof(GZipCompressor),
                                                              typeof(DeflateCompressor),
                                                              typeof(SevenZipCompressor))] Type compressorType,
                                                          [Values(typeof(AriaSymmetricEncryptor),
                                                              typeof(RC2SymmetricEncryptor),
                                                              typeof(TripleDESSymmetricEncryptor))] Type encryptorType) {
            var xmlSerializer = XmlSerializer<List<User>>.Instance;
            var compressor = (ICompressor)ActivatorTool.CreateInstance(compressorType);
            var encryptor = (ISymmetricEncryptor)ActivatorTool.CreateInstance(encryptorType);

            var serializer = new CompressSerializer<List<User>>(new EncryptSerializer<List<User>>(xmlSerializer, encryptor), compressor);

            var users = GetSampleUsers(10);

            var usersData = serializer.Serialize(users);
            var deserializedUsers = serializer.Deserialize(usersData);

            CollectionAssert.AreEqual(users, deserializedUsers);
        }