/// <summary>
        /// Tries to obtains a <see cref="RangeShardMap{TKey}"/> given the name.
        /// </summary>
        /// <typeparam name="TKey">Key type.</typeparam>
        /// <param name="shardMapName">Name of shard map.</param>
        /// <param name="shardMap">Shard map with the specified name.</param>
        /// <returns><c>true</c> if shard map with the specified name was found, <c>false</c> otherwise.</returns>
        public bool TryGetRangeShardMap <TKey>(string shardMapName, out RangeShardMap <TKey> shardMap)
        {
            ShardMapManager.ValidateShardMapName(shardMapName);

            using (ActivityIdScope activityIdScope = new ActivityIdScope(Guid.NewGuid()))
            {
                Tracer.TraceVerbose(
                    TraceSourceConstants.ComponentNames.ShardMapManager,
                    "TryGetRangeShardMap",
                    "Start; ShardMap: {0}",
                    shardMapName);

                shardMap = this.LookupAndConvertShardMapHelper <RangeShardMap <TKey> >(
                    "TryGetRangeShardMap",
                    shardMapName,
                    ShardMapExtensions.AsRangeShardMap <TKey>,
                    false);

                Tracer.TraceInfo(
                    TraceSourceConstants.ComponentNames.ShardMapManager,
                    "TryGetRangeShardMap",
                    "Complete; ShardMap: {0}",
                    shardMapName);

                return(shardMap != null);
            }
        }
        /// <summary>
        /// Obtains a <see cref="ShardMap"/> given the name.
        /// </summary>
        /// <param name="shardMapName">Name of shard map.</param>
        /// <returns>Shardmap with the specificed name.</returns>
        public ShardMap GetShardMap(string shardMapName)
        {
            ShardMapManager.ValidateShardMapName(shardMapName);

            using (ActivityIdScope activityIdScope = new ActivityIdScope(Guid.NewGuid()))
            {
                Tracer.TraceVerbose(
                    TraceSourceConstants.ComponentNames.ShardMapManager,
                    "GetShardMap",
                    "Start; ShardMap: {0}",
                    shardMapName);

                ShardMap shardMap = this.LookupAndConvertShardMapHelper <ShardMap>(
                    "GetShardMap",
                    shardMapName,
                    (sm, t) => sm,
                    true);

                Debug.Assert(shardMap != null);

                Tracer.TraceInfo(
                    TraceSourceConstants.ComponentNames.ShardMapManager,
                    "GetShardMap",
                    "Complete; ShardMap: {0}",
                    shardMapName);

                return(shardMap);
            }
        }
        /// <summary>
        /// Obtains a <see cref="ListShardMap{TKey}"/> given the name.
        /// </summary>
        /// <typeparam name="TKey">Key type.</typeparam>
        /// <param name="shardMapName">Name of shard map.</param>
        /// <returns>Resulting ShardMap.</returns>
        public ListShardMap <TKey> GetListShardMap <TKey>(string shardMapName)
        {
            ShardMapManager.ValidateShardMapName(shardMapName);

            using (ActivityIdScope activityIdScope = new ActivityIdScope(Guid.NewGuid()))
            {
                Tracer.TraceVerbose(
                    TraceSourceConstants.ComponentNames.ShardMapManager,
                    "GetListShardMap",
                    "Start; ShardMap: {0}",
                    shardMapName);

                ListShardMap <TKey> shardMap = this.LookupAndConvertShardMapHelper <ListShardMap <TKey> >(
                    "GetListShardMap",
                    shardMapName,
                    ShardMapExtensions.AsListShardMap <TKey>,
                    true);

                Debug.Assert(shardMap != null);

                Tracer.TraceInfo(
                    TraceSourceConstants.ComponentNames.ShardMapManager,
                    "GetListShardMap",
                    "Complete; ShardMap: {0}",
                    shardMapName);

                return(shardMap);
            }
        }
        /// <summary>
        /// Creates a list based <see cref="ListShardMap{TKey}"/>.
        /// </summary>
        /// <typeparam name="TKey">Type of keys.</typeparam>
        /// <param name="shardMapName">Name of shard map.</param>
        /// <returns>List shard map with the specified name.</returns>
        public ListShardMap <TKey> CreateListShardMap <TKey>(string shardMapName)
        {
            ShardMapManager.ValidateShardMapName(shardMapName);

            using (ActivityIdScope activityIdScope = new ActivityIdScope(Guid.NewGuid()))
            {
                DefaultStoreShardMap dssm = new DefaultStoreShardMap(
                    Guid.NewGuid(),
                    shardMapName,
                    ShardMapType.List,
                    ShardKey.ShardKeyTypeFromType(typeof(TKey)));

                ListShardMap <TKey> listShardMap = new ListShardMap <TKey>(this, dssm);

                Tracer.TraceInfo(
                    TraceSourceConstants.ComponentNames.ShardMapManager,
                    "CreateListShardMap",
                    "Start; ShardMap: {0}",
                    shardMapName);

                Stopwatch stopwatch = Stopwatch.StartNew();

                this.AddShardMapToStore("CreateListShardMap", dssm);

                stopwatch.Stop();

                Tracer.TraceInfo(
                    TraceSourceConstants.ComponentNames.ShardMapManager,
                    "CreateListShardMap",
                    "Added ShardMap to Store; ShardMap: {0} Duration: {1}",
                    shardMapName,
                    stopwatch.Elapsed);

                Tracer.TraceInfo(
                    TraceSourceConstants.ComponentNames.ShardMapManager,
                    "CreateListShardMap",
                    "Complete; ShardMap: {0} Duration: {1}",
                    shardMapName,
                    stopwatch.Elapsed);

                return(listShardMap);
            }
        }