Ejemplo n.º 1
0
        public RecentFiles(PermanentSettings permanentSettings, ICommand command)
        {
            this.permanentSettings = permanentSettings;
            this.command           = command;

            this.MaxFiles = 5;

            this.Read();
        }
        public PermanentSettings(String fileName)
        {
            _fileName = fileName;

            using (var isolatedStorageFile = IsolatedStorageFile.GetUserStoreForAssembly())
            {
                using (var streamReader = new StreamReader(new IsolatedStorageFileStream(_fileName, FileMode.OpenOrCreate, isolatedStorageFile)))
                {
                    while (!streamReader.EndOfStream)
                    {
                        var parts = streamReader.ReadLine().Split('=');
                        if (parts.Length != 3)
                        {
                            continue;
                        }

                        var type = GetType(parts[1]);
                        if (null == type)
                        {
                            continue;
                        }

                        try
                        {
                            _settings.Add(parts[0], Convert.ChangeType(parts[2], type)); // normal type
                        }
                        catch
                        {
                            try
                            {
                                _settings.Add(parts[0], Enum.Parse(type, parts[2])); // enums
                            }
                            catch
                            {
                            }
                        }
                    }
                }
            }

            Instance = this;
        }
 public void CopyFrom(PermanentSettings permanentSettings, String name)
 {
     this.Set(name, permanentSettings.Get(name));
 }