public static string ToDescription(this EnumStorageStatusCode en) { switch (en) { case EnumStorageStatusCode.Success: return("Success"); case EnumStorageStatusCode.Failure: return("Failure"); case EnumStorageStatusCode.DidNotSave: return("Did not save"); case EnumStorageStatusCode.KeyExists: return("Key already exists"); case EnumStorageStatusCode.KeyNotFound: return("Ley was not found"); case EnumStorageStatusCode.KeyIsNull: return("Passed key is null, not allowed"); case EnumStorageStatusCode.ValueIsNull: return("Passed value is null, not allowed"); default: return(string.Empty); throw new ArgumentOutOfRangeException(nameof(en), en, null); } }
public string Get(string key, out EnumStorageStatusCode statusCode) { if (string.IsNullOrWhiteSpace(key)) { statusCode = EnumStorageStatusCode.KeyIsNull; return(null); } key = key.ToLower(); var index = Items.FindIndex(x => x.Key == key); if (index == -1) { statusCode = EnumStorageStatusCode.KeyNotFound; return(null); } if (Items[index].IsEncrypted) { // decrypt the value var decryptedValue = Utilities.Security.Decrypt(Items[index].Value); statusCode = EnumStorageStatusCode.Success; return(decryptedValue); } else { statusCode = EnumStorageStatusCode.Success; return(Items[index].Value); } }