Beispiel #1
0
        public bool Delete(string key)
        {
            var query = strategy.KeyToQuery(key);
            var code  = SecKeyChain.Remove(query);

            SecureStoreStrategyExtensions.AssertOk(code);
            return(code != SecStatusCode.ItemNotFound);
        }
Beispiel #2
0
        public void Set <T>(string key, T value)
        {
            SecStatusCode result;
            var           query  = strategy.KeyToQuery(key);
            var           record = SecKeyChain.QueryAsRecord(query, out result);

            SecureStoreStrategyExtensions.AssertOk(result);
            if (record != null)
            {
                strategy.Write(record, value);
                result = SecKeyChain.Update(query, record);
                SecureStoreStrategyExtensions.AssertOk(result);
            }
            else
            {
                record = strategy.KeyToQuery(key);
                strategy.Write(record, value);
                result = SecKeyChain.Add(record);
                SecureStoreStrategyExtensions.AssertOk(result);
            }
        }