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()); }
/// <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()); }