Пример #1
0
        /// <summary>
        /// Loads ClientSettings from a file.
        /// </summary>
        /// <param name="file">File path to load from.</param>
        /// <returns>An instance of ClientSettings class.</returns>
        public static ClientSettings Load(string file)
        {
            if (!File.Exists(file))
            {
                ClientSettings cfg = new ClientSettings();
                Save(file, cfg);

                return cfg;
            }

            // TODO: MAke this binary
            System.Xml.Serialization.XmlSerializer xs
               = new System.Xml.Serialization.XmlSerializer(
                  typeof(ClientSettings));
            StreamReader reader = File.OpenText(file);
            ClientSettings c = new ClientSettings();
            try
            {
                c = (ClientSettings)xs.Deserialize(reader);
            }
            catch (Exception)
            {
            }
            reader.Close();
            return c;
        }
Пример #2
0
        /// <summary>
        /// Saves the Client Settings
        /// </summary>
        /// <param name="file">File path to save to</param>
        /// <param name="c">ClientSettings object</param>
        public static void Save(string file,ClientSettings c)
        {
            try
            {
                if (File.Exists(file))
                    File.Delete(file);

                // TODO: MAke this binary
                System.Xml.Serialization.XmlSerializer xs
                   = new System.Xml.Serialization.XmlSerializer(c.GetType());
                StreamWriter writer = File.CreateText(file);
                xs.Serialize(writer, c);
                writer.Flush();
                writer.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #3
0
        // Region for Construcor
        #region Constructor
        
        /// <summary>
        /// Constructor for Facade class.
        /// Use GetInstance() instead.
        /// </summary>
        private Facade()
        {
            // Load Account Settings.
            this._accSettings = AccountSettings.Load("Account.Settings");

            // Load Client Settings.
            this._clientSettings = ClientSettings.Load("Client.Settings");

            // Setup Message Server.
            this._store = new MessageStore();

            // Setup Message Server Sent Items.
            this._storeSent = new MessageStore();

            // Setup Message Server Deleted Items.
            this._storeDelete = new MessageStore();

            // Setup Message Server Custom Folders.
            this._storeCustom = new MessageStore();

            // Imap4 controller instance.
            this._imap4Controller = new Imap4Controller(this.GetDefaultAccountInfo());

            // Pop3 controller instance.
            this._pop3Controller = new Pop3Controller(this.GetDefaultAccountInfo());

            // Smtp controller instance.
            this._smtpController = new SmtpController();
        }