Exemple #1
0
 /// <summary>
 ///     Prepends a single value to a sequence.
 /// </summary>
 /// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam>
 /// <param name="source">The sequence to prepend to.</param>
 /// <param name="value">The value to prepend.</param>
 /// <returns>
 ///     Returns a sequence where a value is prepended to it.
 /// </returns>
 /// <remarks>
 ///     This operator uses deferred execution and streams its results.
 /// </remarks>
 /// <code>
 /// int[] numbers = { 1, 2, 3 };
 /// IEnumerable&lt;int&gt; result = numbers.Prepend(0);
 /// </code>
 /// The
 /// <c>result</c>
 /// variable, when iterated over, will yield
 /// 0, 1, 2 and 3, in turn.
 public static IEnumerable <TSource> Prepend <TSource>(this IEnumerable <TSource> source, TSource value)
 {
     if (source == null)
     {
         throw new ArgumentNullException("source");
     }
     return(LinqEnumerable.Concat(LinqEnumerable.Repeat(value, 1), source));
 }
Exemple #2
0
        /// <summary>
        /// Returns a sequence consisting of the head elements and the given tail element.
        /// </summary>
        /// <typeparam name="T">Type of sequence</typeparam>
        /// <param name="head">All elements of the head. Must not be null.</param>
        /// <param name="tail">Tail element of the new sequence.</param>
        /// <returns>A sequence consisting of the head elements and the given tail element.</returns>
        /// <remarks>This operator uses deferred execution and streams its results.</remarks>

        public static IEnumerable <T> Concat <T>(this IEnumerable <T> head, T tail)
        {
            if (head == null)
            {
                throw new ArgumentNullException(nameof(head));
            }
            return(LinqEnumerable.Concat(head, LinqEnumerable.Repeat(tail, 1)));
        }
 public ReturnShortModelAttribute(Type model, params Type[] models)
 {
     if (models != null && models.Any())
     {
         Models = Enumerable.ToArray(Enumerable.Concat(models, new[] { model, }));
     }
     else
     {
         Models = new[] { model, };
     }
 }
Exemple #4
0
 public override IEnumerator <TSource> GetEnumerator()
 {
     return(SL.Concat(source, source2).GetEnumerator());
 }
Exemple #5
0
        /// <summary>
        /// Prepends a single value to a sequence.
        /// </summary>
        /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam>
        /// <param name="source">The sequence to prepend to.</param>
        /// <param name="value">The value to prepend.</param>
        /// <returns>
        /// Returns a sequence where a value is prepended to it.
        /// </returns>
        /// <remarks>
        /// This operator uses deferred execution and streams its results.
        /// </remarks>
        /// <code>
        /// int[] numbers = { 1, 2, 3 };
        /// IEnumerable&lt;int&gt; result = numbers.Prepend(0);
        /// </code>
        /// The <c>result</c> variable, when iterated over, will yield
        /// 0, 1, 2 and 3, in turn.

        public static IEnumerable <TSource> Prepend <TSource> (this IEnumerable <TSource> source, TSource value)
        {
            source.ThrowIfNull("source");
            return(LinqEnumerable.Concat(LinqEnumerable.Repeat(value, 1), source));
        }
Exemple #6
0
 /// <summary>
 /// Returns a sequence consisting of the head elements and the given tail element.
 /// </summary>
 /// <typeparam name="T">Type of sequence</typeparam>
 /// <param name="head">All elements of the head. Must not be null.</param>
 /// <param name="tail">Tail element of the new sequence.</param>
 /// <returns>A sequence consisting of the head elements and the given tail element.</returns>
 /// <remarks>This operator uses deferred execution and streams its results.</remarks>
 public static IEnumerable <T> Concat <T> (this IEnumerable <T> head, T tail)
 {
     head.ThrowIfNull("head");
     return(LinqEnumerable.Concat(head, LinqEnumerable.Repeat(tail, 1)));
 }