コード例 #1
0
        /// <summary>Convert an item into a key of this subspace</summary>
        /// <param name="item">Convertible item that will be packed and appended to the subspace prefix</param>
        public Slice Pack([NotNull] ITupleFormattable item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            return(Pack(item.ToTuple()));
        }
コード例 #2
0
        /// <summary>Create a new key by appending a formattable object to the current subspace</summary>
        /// <param name="item">Instance of a type that can be transformed into a Tuple</param>
        /// <returns>Key the correspond to the concatenation of the current subspace's prefix and the packed representation of the tuple returned by <paramref name="item"/>.ToTuple()</returns>
        /// <exception cref="System.ArgumentNullException">If <paramref name="item"/> is null</exception>
        /// <exception cref="System.InvalidOperationException">If calling <paramref name="item"/>.ToTuple() returns null.</exception>
        public static Slice Pack(this IFdbSubspace subspace, [NotNull] ITupleFormattable item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }
            var tuple = item.ToTuple();

            if (tuple == null)
            {
                throw new InvalidOperationException("The specified item returned a null tuple");
            }
            return(Pack(subspace, tuple));
        }
コード例 #3
0
        public static IFdbTuple Append(this IFdbSubspace subspace, [NotNull] ITupleFormattable formattable)
        {
            if (formattable == null)
            {
                throw new ArgumentNullException("formattable");
            }
            var tuple = formattable.ToTuple();

            if (tuple == null)
            {
                throw new InvalidOperationException("Formattable item cannot return an empty tuple");
            }
            return(new FdbPrefixedTuple(subspace.ToFoundationDbKey(), tuple));
        }
コード例 #4
0
        public static FdbSubspace Partition(this IFdbSubspace subspace, [NotNull] ITupleFormattable formattable)
        {
            if (formattable == null)
            {
                throw new ArgumentNullException("formattable");
            }
            var tuple = formattable.ToTuple();

            if (tuple == null)
            {
                throw new InvalidOperationException("Formattable item returned an empty tuple");
            }
            return(Partition(subspace, tuple));
        }
コード例 #5
0
        public ITuple Concat([NotNull] ITupleFormattable formattable)
        {
            if (formattable == null)
            {
                throw new ArgumentNullException("formattable");
            }
            var tuple = formattable.ToTuple();

            if (tuple == null)
            {
                throw new InvalidOperationException("Formattable item cannot return an empty tuple");
            }
            return(new PrefixedTuple(this.Subspace.Key, tuple));
        }
コード例 #6
0
 public                              IFdbDynamicSubspace this[ITupleFormattable item]
 {
     [ContractAnnotation("null => halt; notnull => notnull")]
     get
     {
         Contract.NotNull(item, nameof(item));
         var tuple = item.ToTuple();
         if (tuple == null)
         {
             throw new InvalidOperationException("Formattable item returned an empty tuple");
         }
         return(this[tuple]);
     }
 }
コード例 #7
0
 /// <summary>Convert an item into a key of this subspace</summary>
 /// <param name="item">Convertible item that will be packed and appended to the subspace prefix</param>
 /// <remarks>This is a shortcut for <see cref="Pack(ITupleFormattable)"/></remarks>
 public                                       Slice this[[NotNull] ITupleFormattable item]
 {
     get { return(Pack(item)); }
 }
コード例 #8
0
 /// <summary>Return a key range that encompass all the keys inside a partition of this subspace, according to the current key encoder</summary>
 /// <param name="item">Convertible item used as a prefix for the range</param>
 public KeyRange ToRange([NotNull] ITupleFormattable item)
 {
     return(this.Encoder.ToRange(Pack(item)));
 }