コード例 #1
0
        public static StoredSecret FromTable(CloudTable table, string name, int? version)
        {
            if (!version.HasValue)
            {
                var exists = Cloud.GetCoud().GetObject<StoredSecret>(table, Cloud.GetCoud().ToKey(name));
                version = exists.Count();
            }

            var reader = new StoredSecret(new StoredSecret() { Name = name, Version = version.Value});

            return Cloud.GetCoud().GetObject<StoredSecret>(table, reader.PartitionKey, reader.RowKey);
        }
コード例 #2
0
        /// <summary>
        /// Creates a secret
        /// </summary>
        /// <param name="secretName">A secret</param>
        /// <param name="secret">More data about the secret</param>
        /// <returns>The saved secret</returns>
        public ISecret CreateSecret(string secretName, ISecret secret)
        {
            secret.Name = secretName;

            var store = new StoredSecret(secret);
            var table = _cloud.GetTable(Table, _connectionString);
            var exists = GetAllSecrets(table, store);

            store.Version = exists.Count() + 1;

            store = new StoredSecret(store);

            return _cloud.SetObject(table, store);
        }
コード例 #3
0
 /// <summary>
 /// Get all partition keys
 /// </summary>
 /// <param name="secret">Gets all the secrets</param>
 /// <returns></returns>
 private IEnumerable<StoredSecret> GetAllSecrets(CloudTable table, StoredSecret secret)
 {
     return _cloud.GetObject<StoredSecret>(table, secret.PartitionKey);
 }