Ejemplo n.º 1
0
        public void WriteConnectionsData(IList <EmailConnectionData> emailConnectionsData)
        {
            var emailConnectionData = new EmailConnectionDataContainer()
            {
                EmailConnectionsData = emailConnectionsData
            };

            var binaryFormatter = new BinaryFormatter();

            using (var stream = new FileStream("data.dat", FileMode.Create, FileAccess.Write, FileShare.None))
            {
                binaryFormatter.Serialize(stream, emailConnectionsData);
            }
        }
Ejemplo n.º 2
0
        public void AddConnectionsData(IList <EmailConnectionData> addedEmailConnectionsData)
        {
            var emailDataReader         = new EmailDataReader();
            var newEmailConnectionsData = new List <EmailConnectionData>(emailDataReader.ReadConnectionsData());

            newEmailConnectionsData.AddRange(addedEmailConnectionsData);

            var emailDataConnectionsData = new EmailConnectionDataContainer()
            {
                EmailConnectionsData = newEmailConnectionsData
            };

            var binaryFormatter = new BinaryFormatter();

            using (var stream = new FileStream("data.dat", FileMode.Create, FileAccess.Write, FileShare.None))
            {
                binaryFormatter.Serialize(stream, addedEmailConnectionsData);
            }
        }