Exemplo n.º 1
0
        public static PersistentContainer Load(string fileName)
        {
            string json            = ReadFile(fileName);
            PersistentContainer pc = JsonConvert.DeserializeObject <PersistentContainer>(json);

            return(pc);
        }
Exemplo n.º 2
0
        private void button_save_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(textBoxPersistanceFile.Text))
            {
                MessageBox.Show("File Textbox is blank");
            }
            else
            {
                PersistentContainer pc = new PersistentContainer();
                pc.MailBody                = textBoxMailBody.Text;
                pc.MailServer              = textBoxMailServer.Text;
                pc.MailSubject             = textBoxMailSubject.Text;
                pc.MailUsername            = textBoxMailUserName.Text;
                pc.DestinationEmailAddress = textBoxDestinationEmailAddress.Text;
                pc.EmailEntries            = new List <EmailEntry>();

                foreach (var control in flowLayoutPanelMailSender.Controls)
                {
                    if (control is EmailEntryForm)
                    {
                        EmailEntryForm eef = (EmailEntryForm)control;
                        EmailEntry     ee  = new EmailEntry();
                        ee.EmailAdress = eef.TextBoxSenderEmailText;
                        ee.ContactInfo = eef.TextBoxSenderFooterText;
                        ee.Name        = eef.TextBoxSenderNameText;
                        pc.EmailEntries.Add(ee);
                    }
                }

                Persister.Store(textBoxPersistanceFile.Text, pc);
            }
        }
Exemplo n.º 3
0
        private void button_load_Click(object sender, EventArgs e)
        {
            if (!File.Exists(textBoxPersistanceFile.Text))
            {
                MessageBox.Show("File " + textBoxPersistanceFile.Text + " does not exists!");
            }
            else
            {
                PersistentContainer pc = Persister.Load(textBoxPersistanceFile.Text);
                flowLayoutPanelMailSender.Controls.Clear();

                textBoxMailBody.Text                = pc.MailBody;
                textBoxMailServer.Text              = pc.MailServer;
                textBoxMailUserName.Text            = pc.MailUsername;
                textBoxMailSubject.Text             = pc.MailSubject;
                textBoxDestinationEmailAddress.Text = pc.DestinationEmailAddress;

                foreach (EmailEntry ee in pc.EmailEntries)
                {
                    EmailEntryForm eef = new EmailEntryForm();
                    eef.TextBoxSenderNameText   = ee.Name;
                    eef.TextBoxSenderEmailText  = ee.EmailAdress;
                    eef.TextBoxSenderFooterText = ee.ContactInfo;
                    flowLayoutPanelMailSender.Controls.Add(eef);
                }
            }
        }
Exemplo n.º 4
0
        public static void Store(string fileName, PersistentContainer persistentContainer)
        {
            string json = JsonConvert.SerializeObject(persistentContainer);

            WriteFile(fileName, json);
        }