Пример #1
0
        public static Peers ReadPeers()
        {
            string path  = System.IO.Directory.GetCurrentDirectory() + "\\peers.json";
            Peers  peers = new Peers();

            using (StreamReader file = File.OpenText(path))
            {
                JsonSerializer serializer = new JsonSerializer();
                peers = (Peers)serializer.Deserialize(file, typeof(Peers));
            }
            return(peers);
        }
Пример #2
0
 public void NewPeers(Peers new_peers)
 {
     to_merge.Add(new_peers);
 }
Пример #3
0
        private void ReceivePeers(PacketHeader packetHeader, Connection connection, string peer_list)
        {
            Peers new_peers = Serialize.DeserializePeers(peer_list);

            network.NewPeers(new_peers);
        }
Пример #4
0
 public static void WritePeers(Peers peers)
 {
     //MessageBox.Show("Saving: " + SerializePeers(peers));
     File.WriteAllText(System.IO.Directory.GetCurrentDirectory() + "\\peers.json", SerializePeers(peers));
 }
Пример #5
0
 public static string SerializePeers(Peers peers)
 {
     return(JsonConvert.SerializeObject(peers, Newtonsoft.Json.Formatting.Indented));
 }