Exemplo n.º 1
0
        private static int GetEnumerator(Func <int> handler)
        {
            int count = -1;

            for (int i = 0; i < PER_TEST; i++)
            {
                count = 0;
                if (handler != null)
                {
                    foreach (var sub in handler.AsEnumerable())
                    {
                        count += sub();
                    }
                }
            }
            return(count);
        }
Exemplo n.º 2
0
        private static int GetEnumerator_CheckSingle(Func <int> handler)
        {
            int count = -1;

            for (int i = 0; i < PER_TEST; i++)
            {
                count = 0;
                if (handler == null)
                {
                }
                else if (handler.IsSingle())
                {
                    count = handler();
                }
                else
                {
                    foreach (var sub in handler.AsEnumerable())
                    {
                        count += sub();
                    }
                }
            }
            return(count);
        }
Exemplo n.º 3
0
 public ISequenceBuilder Or(Func <ICommandOutput> returnValue)
 {
     _results.Add(returnValue.AsEnumerable());
     return(this);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Returns the sequence or a singleton default value sequence if it's empty.
 /// </summary>
 /// <typeparam name="T">Source sequence element type.</typeparam>
 /// <param name="source">Source sequence.</param>
 /// <param name="defaultValue">Default value.</param>
 /// <returns>Original sequence or the default value.</returns>
 public static Func <Func <Maybe <T> > > DefaultIfEmpty <T>(this Func <Func <Maybe <T> > > source, T defaultValue)
 {
     return(source.AsEnumerable().DefaultIfEmpty(defaultValue).AsFEnumerable());
 }
Exemplo n.º 5
0
 /// <summary>
 /// Sorts the elements in the sequence by the selected key value in descending order.
 /// </summary>
 /// <typeparam name="T">Source sequence element type.</typeparam>
 /// <typeparam name="K">Key type.</typeparam>
 /// <param name="source">Source sequence.</param>
 /// <param name="keySelector">Key selector.</param>
 /// <returns>Ordered sequence.</returns>
 public static Func <Func <Maybe <T> > > OrderByDescending <T, K>(this Func <Func <Maybe <T> > > source, Func <T, K> keySelector)
 {
     return(new OrderedWrapper <T>(source.AsEnumerable().OrderByDescending(keySelector)).GetEnumerator);
 }
Exemplo n.º 6
0
 protected ISequenceBuilder Either(Func<ICommandOutput> returnValue)
 {
     return new SequenceBuilder(returnValue.AsEnumerable());
 }