Esempio n. 1
0
        public static bool Load()
        {
            // If already loaded...
            if (_stats != null)
            {
                return(true);
            }

            try
            {
                var isoFile = IsolatedStorageFile.GetUserStoreForApplication();
                if (isoFile.FileExists(Filename))
                {
                    var stream     = IsolatedStorageFile.GetUserStoreForApplication().OpenFile(Filename, FileMode.Open);
                    var reader     = new StreamReader(stream);
                    var serializer = new XmlSerializer(typeof(SerializedStatistics));
                    _stats = serializer.Deserialize(reader) as SerializedStatistics;
                    reader.Close();
                }
                else
                {
                    _stats = new SerializedStatistics();
                }
                return(true);
            }
            catch (FileNotFoundException)
            {
                // No statistics file found - that's okay
                return(true);
            }
            catch (Exception exc)
            {
                System.Diagnostics.Debug.WriteLine(exc);
                _stats = new SerializedStatistics();
                return(false);
            }
        }
Esempio n. 2
0
 public static void Reset()
 {
     _stats = new SerializedStatistics();
 }