/// <summary> /// Deserialize from a stream. /// </summary> /// <param name="stream">A stream contains serialize.</param> /// <param name="size">Must be -1.</param> /// <returns>The number of bytes read from the stream.</returns> public int Deserialize(System.IO.Stream stream, int size) { AdapterHelper.Site.Assert.AreEqual(-1, size, "The size value should be -1, but the actual value is {0}.", size); int bytesRead = 0; this.Flags = StreamHelper.ReadUInt32(stream); bytesRead += 4; this.Depth = StreamHelper.ReadUInt32(stream); bytesRead += 4; this.FolderLongTermId = StreamHelper.ReadLongTermId(stream); bytesRead += 0x10 + 6 + 2; this.ServerDNCount = StreamHelper.ReadUInt32(stream); bytesRead += 4; this.CheapServerDNCount = StreamHelper.ReadUInt32(stream); bytesRead += 4; this.ServerDNArray = new string[this.ServerDNCount]; for (int i = 0; i < this.ServerDNCount; i++) { this.ServerDNArray[i] = StreamHelper.ReadString8(stream); } AdapterHelper.Site.Assert.AreEqual(this.ServerDNArray.Length, (int)this.ServerDNCount, "The deserialized serverDN count is not equal to the original server DN count. The expected value of the deserialized server DN is {0}, but the actual value is {1}.", this.ServerDNCount, this.ServerDNArray.Length); bytesRead += Common.GetBytesFromMutiUnicodeString(this.ServerDNArray).Length; return(bytesRead); }