Пример #1
0
        public T GetValue <T>(string key, T defaultValue = default(T), bool shouldDecrpyt = false)
        {
            var value = TypeHelperExtended.IsPrimitive(typeof(T), false) ?
                        GetPrimitive(key, defaultValue) :
                        RetrieveObject(key, defaultValue);

            if (!shouldDecrpyt)
            {
                return(value);
            }

            var decrypted = SimpleStringCipher.Instance.Decrypt(Convert.ToString(value));

            return((T)Convert.ChangeType(decrypted, typeof(T)));
        }
Пример #2
0
 public void SetValue <T>(string key, T value, bool shouldEncrypt = false)
 {
     if (TypeHelperExtended.IsPrimitive(typeof(T), false))
     {
         if (shouldEncrypt)
         {
             InternalSetValue(key, SimpleStringCipher.Instance.Encrypt(Convert.ToString(value)));
         }
         else
         {
             InternalSetValue(key, value);
         }
     }
     else
     {
         SetJsonValue(key, value);
     }
 }