Пример #1
0
        public static bool SaveAppData(string i_pathToSave, ApplicationConfigurationData i_AppData)
        {
            bool resultOfSaveOperation = false;
            StreamWriter dataWriter = null;
            try
            {
                XmlSerializer XmlAppConfigSerializer = new XmlSerializer(i_AppData.GetType());
                dataWriter = new StreamWriter(i_pathToSave);
                XmlAppConfigSerializer.Serialize(dataWriter, i_AppData);
                resultOfSaveOperation = true;
            }            
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                if (dataWriter != null)
                {
                    dataWriter.Close();
                }
            }

            return resultOfSaveOperation;
        }
Пример #2
0
        public static bool LoadAppData(string i_PathToLoad, ref ApplicationConfigurationData i_AppData)
        {
            bool resultOfLoad = false;
            StreamReader dataReader = null;

            if (File.Exists(i_PathToLoad))
            {
                try
                {
                    XmlSerializer XmlAppConfigDeserializer = new XmlSerializer(i_AppData.GetType());
                    dataReader = new StreamReader(i_PathToLoad);
                    i_AppData = (ApplicationConfigurationData)XmlAppConfigDeserializer.Deserialize(dataReader);
                    if (i_AppData != null)
                    {
                        resultOfLoad = true;
                    }
                }
                catch (Exception e)
                {
                    throw e;
                }
                finally
                {
                    if (dataReader != null)
                    {
                        dataReader.Close();
                    }
                }
            }

            return resultOfLoad;
        }
Пример #3
0
        // add icons to all Forms
        public FormMain()
        {
            m_AppConfig = new ApplicationConfigurationData();

            InitializeComponent();
            FacebookWrapper.FacebookService.s_CollectionLimit = 1000;

            if (SaveLoadUtil.LoadAppData(m_PathOfAppDataFile, ref m_AppConfig))
            {
                if (m_AppConfig.RememberMe)
                {
                    autoLogin();
                }
            }
        }
Пример #4
0
        public static bool SaveAppData(string i_pathToSave, ApplicationConfigurationData i_AppData)
        {
            bool resultOfSaveOperation = false;
            // TODO: using
            try
            {
                XmlSerializer XmlAppConfigSerializer = new XmlSerializer(i_AppData.GetType());
                StreamWriter dataWriter = new StreamWriter(i_pathToSave);
                XmlAppConfigSerializer.Serialize(dataWriter, i_AppData);
                dataWriter.Dispose();
                resultOfSaveOperation = true;
            }
            catch (Exception e)
            {
                throw e;
            }

            return resultOfSaveOperation;
        }
Пример #5
0
        // added static factory class for the like analyzer form and the music form.
        public FormMain()
        {            
            m_AppConfig = new ApplicationConfigurationData();
            InitializeComponent();
            FacebookWrapper.FacebookService.s_CollectionLimit = 1000;

            try
            {
                if (SaveLoadUtil.LoadAppData(m_PathOfAppDataFile, ref m_AppConfig))
                {
                    if (m_AppConfig.RememberMe)
                    {
                        autoLogin();
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Error in loading configuration!");
            }
        }