示例#1
0
        public byte[] Serialize()
        {
            using var memory = new MemoryStream();
            using var writer = new BinaryWriter(memory);

            IntegerUtil.Serialize(Peers.Count, writer);

            Peers.ForEach(x => new TLObject(x.AsTLObject()).Serialize(writer));

            return(memory.ToArray());
        }
示例#2
0
 /// <summary>
 /// Deserilizes a PeerManager object from a stream
 /// </summary>
 /// <param name="reader">The stream containing the raw PeerManager data</param>
 public static PeerInfo[] Deserialize(BinaryReader reader)
 {
     return(Enumerable.Range(0, IntegerUtil.Deserialize(reader))
            .Select(x => new PeerInfo(TLObject.Deserialize(reader)))
            .ToArray());
 }