Exemplo n.º 1
0
        /// <summary>
        /// Delete the existing reliable collection for this index.
        /// This is called internally and should not be directly called.
        /// </summary>
        async Task IIndexDefinition <TKey, TValue> .RemoveIndexAsync(ITransaction tx, IReliableStateManager stateManager, Uri baseName, TimeSpan timeout)
        {
            var indexName = GetIndexName(baseName);
            await stateManager.RemoveAsync(tx, indexName, timeout).ConfigureAwait(false);

            _index = null;
        }
        /// <summary>
        /// Remove an existing <see cref="IReliableIndexedDictionary{TKey, TValue}"/> with the given name, along with its indexes.
        /// The state is permanently removed from storage and all replicas when this transaction commits.
        /// </summary>
        /// <remarks>
        /// The index definitions indicate the indexes that should be created, or which should exist with this reliable collection.  The index definitions should be
        /// consistent when creating/reading/removing reliable collections, and should not be changed after creation.  Doing so can cause the index to become out of sync
        /// with the primary reliable collection, which will cause runtime exceptions.
        /// </remarks>
        public static async Task RemoveIndexedAsync <TKey, TValue>(this IReliableStateManager stateManager, ITransaction tx, string name, TimeSpan timeout, params IIndexDefinition <TKey, TValue>[] indexes)
            where TKey : IComparable <TKey>, IEquatable <TKey>
        {
            var result = await stateManager.TryGetAsync <IReliableDictionary2 <TKey, TValue> >(name).ConfigureAwait(false);

            if (result.HasValue)
            {
                await stateManager.RemoveAsync(tx, name, timeout).ConfigureAwait(false);

                await stateManager.RemoveIndexedAsync(tx, GetBaseIndexUri(name), timeout, indexes).ConfigureAwait(false);
            }
        }
Exemplo n.º 3
0
        public async Task ClearAsync(params string[] storeNames)
        {
            var enumerator = _stateManager.GetAsyncEnumerator();

            while (await enumerator.MoveNextAsync(CancellationToken.None))
            {
                if (storeNames.Contains(enumerator.Current.Name.LocalPath))
                {
                    await _stateManager.RemoveAsync(enumerator.Current.Name.LocalPath);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Remove an existing <see cref="IReliableIndexedDictionary{TKey, TValue}"/> with the given name, along with its indexes.
        /// The state is permanently removed from storage and all replicas when this transaction commits.
        /// </summary>
        /// <remarks>
        /// The index definitions indicate the indexes that should be created, or which should exist with this reliable collection.  The index definitions should be
        /// consistent when creating/reading/removing reliable collections, and should not be changed after creation.  Doing so can cause the index to become out of sync
        /// with the primary reliable collection, which will cause runtime exceptions.
        /// </remarks>
        public static async Task RemoveIndexedAsync <TKey, TValue>(this IReliableStateManager stateManager, ITransaction tx, Uri name, TimeSpan timeout, params IIndexDefinition <TKey, TValue>[] indexes)
            where TKey : IComparable <TKey>, IEquatable <TKey>
        {
            await stateManager.RemoveAsync(tx, name, timeout).ConfigureAwait(false);

            // Remove all the indexes.
            Uri baseName = GetBaseIndexUri(name);

            foreach (var index in indexes)
            {
                await index.RemoveIndexAsync(tx, stateManager, baseName, timeout).ConfigureAwait(false);
            }
        }