Esempio n. 1
0
        private static void Load()
        {
            if (ValuesController.HasKey("currentUserIdentifier"))
            {
                ActiveUserId = ValuesController.GetValue <EntityId>("currentUserIdentifier");
            }

            if (ValuesController.HasKey("deviceId"))
            {
                DeviceId = ValuesController.GetValue <EntityId>("deviceId");
            }
            if (ValuesController.HasKey("installId"))
            {
                InstallationId = ValuesController.GetValue <EntityId>("installationId");
            }

            if (FileController.Exists("userSettings"))
            {
                Users = MessagePackSerializer.Deserialize <List <UserSettings> >(FileController.ReadAllBytes("userSettings"));
            }
            else
            {
                Users = new List <UserSettings>();
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Gets an int.
 /// </summary>
 /// <returns>The int if found or -1 if an error occured.</returns>
 /// <param name="key">Key.</param>
 public static int GetInt(string key)
 {
     try
     {
         return(BitConverter.ToInt32(FileController.ReadAllBytes("data" + key), 0));
     }
     catch (FileNotFoundException)
     {
         return(-1);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Gets the string.
 /// </summary>
 /// <returns>The string found under that key.</returns>
 /// <param name="key">Key.</param>
 public static string GetString(string key)
 {
     try
     {
         return(Encoding.UTF8.GetString(FileController.ReadAllBytes(SaveKeyWithPrefix(key))));
     }
     catch (FileNotFoundException)
     {
         return(null);
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Loads data from disc and tries to decrypt it.
 /// </summary>
 /// <returns>The decrypted data.</returns>
 /// <param name="relativePath">Relative path.</param>
 public byte[] LoadData(string relativePath)
 {
     return(Decrypt(FileController.ReadAllBytes(relativePath)));
 }