Ejemplo n.º 1
0
        public static UserOptions Load()
        {
            using (var file = IsolatedStorageFile.GetUserStoreForAssembly())
            {
                if (file.FileExists(ConfigFileName) && Monitor.TryEnter(ConfigFileName, 2000))
                {
                    try
                    {
                        using (var stream = file.OpenFile(ConfigFileName, FileMode.Open, FileAccess.Read, FileShare.Read))
                        {
                            return(Load(stream));
                        }
                    }
                    catch
                    {
                        MessageBox.Show("Не удалось загрузить настройки пользователя! Будут использованы настройки по умолчанию.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    finally
                    {
                        Monitor.Exit(ConfigFileName);
                    }
                }
            }

            var newSettings = new UserOptions();

            newSettings.Initialize();
            return(newSettings);
        }
Ejemplo n.º 2
0
 static UserOptions()
 {
     Default = Load();
 }