/// <summary>Test if the start of current tuple is equal to another tuple</summary>
        /// <param name="left">Larger tuple</param>
        /// <param name="right">Smaller tuple</param>
        /// <returns>True if the beginning of <paramref name="left"/> is equal to <paramref name="right"/> or if both tuples are identical</returns>
        public static bool StartsWith([NotNull] this IFdbTuple left, [NotNull] IFdbTuple right)
        {
            if (left == null)
            {
                throw new ArgumentNullException("left");
            }
            if (right == null)
            {
                throw new ArgumentNullException("right");
            }

            //REVIEW: move this on IFdbTuple interface ?
            return(FdbTuple.StartsWith(left, right));
        }
Exemple #2
0
        /// <summary>Create a formatter that just add or remove a prefix to values</summary>
        public static ITupleFormatter <T> CreateAppender(IFdbTuple prefix)
        {
            if (prefix == null)
            {
                throw new ArgumentNullException("prefix");
            }

            return(new FdbAnonymousTupleFormatter <T>(
                       (value) => prefix.Append <T>(value),
                       (tuple) =>
            {
                if (tuple.Count != prefix.Count + 1)
                {
                    throw new ArgumentException("Tuple size is invalid", "tuple");
                }
                if (!FdbTuple.StartsWith(tuple, prefix))
                {
                    throw new ArgumentException("Tuple does not start with the expected prefix", "tuple");
                }
                return tuple.Last <T>();
            }
                       ));
        }