Пример #1
0
        public static int Next(CloudTable table, string partition_key)
        {
            lock (table)
            {
                DynamicTableEntity entity = retrieveEntity(table, partition_key);                               // null for nonexistent board.
                TableRowPond.Notify(table, entity.PartitionKey, entity.RowKey);

                int n_value = (int)entity["nextid"].Int32Value;
                entity["nextid"].Int32Value = n_value + 1;

                table.Execute(TableOperation.Replace(entity));                      // Throws StorageException ((412) Precondition Failed) if the entity is modified in between.

                return(n_value);
            }
        }
Пример #2
0
        private static DynamicTableEntity retrieveEntity(CloudTable table, string partition_key)
        {
            string row_key = partition_key == null ? EMPTY_ROW_KEY : INFO_ROW_KEY;

            if (partition_key == null)
            {
                partition_key = INFO_PAR_KEY;
            }

#if OLD
            TableResult result = table.Execute(TableOperation.Retrieve(partition_key, row_key));
            return((DynamicTableEntity)result.Result);
#else
            return(TableRowPond.Get(table, partition_key, row_key));                    // May be null.
#endif
        }