コード例 #1
0
ファイル: Options.cs プロジェクト: Almahmudrony/spider
        public static bool Load()
        {
            // If already loaded...
            if (_options != null)
            {
                return(true);
            }

            try
            {
                var isoFile = IsolatedStorageFile.GetUserStoreForApplication();
                if (isoFile.FileExists(Filename))
                {
                    var        stream     = IsolatedStorageFile.GetUserStoreForApplication().OpenFile(Filename, FileMode.Open);
                    TextReader reader     = new StreamReader(stream);
                    var        serializer = new XmlSerializer(typeof(SerializedOptions));
                    _options = serializer.Deserialize(reader) as SerializedOptions;
                    reader.Close();
                }
                return(true);
            }
            catch (FileNotFoundException)
            {
                // No options file found - that's okay
                return(true);
            }
            catch (Exception exc)
            {
                System.Diagnostics.Debug.WriteLine(exc);
                return(false);
            }
            finally
            {
                if (_options == null)
                {
                    _options = new SerializedOptions();
                }
            }
        }
コード例 #2
0
ファイル: Options.cs プロジェクト: Almahmudrony/spider
 public static void Reset()
 {
     _options = new SerializedOptions();
 }