Example #1
0
 public void ExcludeCards(Generic.IEnumerable <DominionCard> excludes)
 {
     foreach (var card in excludes)
     {
         this.excludes[card] = true;
     }
 }
Example #2
0
 public static void Apply <T>(this Generic.IEnumerable <T> me, Action <T> function)
 {
     foreach (T element in me)
     {
         function(element);
     }
 }
Example #3
0
 public static Generic.IEnumerable <S> Map <T, S>(this Generic.IEnumerable <T> me, Func <T, S> function)
 {
     foreach (T element in me)
     {
         yield return(function(element));
     }
 }
Example #4
0
 public List(int initialCapacity, Generic.IEnumerable <T> backend) :      this(initialCapacity)
 {
     foreach (var item in backend)
     {
         this.Add(item);
     }
 }
Example #5
0
        public static bool CopyTo <T>(this Generic.IEnumerable <T> me, T[] target, int targetOffset = 0, int count = -1, int sourceOffset = 0)
        {
            bool result;

            if (me is IArrayCopyable <T> )
            {
                result = ((IArrayCopyable <T>)me).CopyTo(target, targetOffset, count, sourceOffset);
            }
            else
            {
                foreach (var element in me)
                {
                    if (targetOffset >= (count == -1 ? target.Length : count))
                    {
                        break;
                    }
                    if (sourceOffset > 0)
                    {
                        sourceOffset--;
                    }
                    else
                    {
                        target[targetOffset++] = element;
                    }
                }
                result = targetOffset > 0;
            }
            return(result);
        }
Example #6
0
 public static S Fold <T, S>(this Generic.IEnumerable <T> me, Func <T, S, S> function, S initial)
 {
     foreach (T element in me)
     {
         initial = function(element, initial);
     }
     return(initial);
 }
Example #7
0
 public static Generic.IEnumerable <byte> Encode(this Generic.IEnumerable <char> me, Encoding encoding)
 {
     Generic.IEnumerator <byte> enumerator = me.GetEnumerator().Encode(encoding);
     while (enumerator.MoveNext())
     {
         yield return(enumerator.Current);
     }
 }
Example #8
0
File: Queue.cs Project: Spaxys/Kean
 public Queue(Generic.IEnumerable <T> data) :
     this()
 {
     foreach (var item in data)
     {
         this.Enqueue(item);
     }
 }
Example #9
0
 public Dictionary(Generic.IEnumerable <KeyValue <TKey, TValue> > data) :
     this()
 {
     foreach (var item in data)
     {
         this[item.Key] = item.Value;
     }
 }
Example #10
0
File: List.cs Project: Spaxys/Kean
 public List(Generic.IEnumerable <T> data) :
     this()
 {
     foreach (var item in data)
     {
         this.Add(item);
     }
 }
Example #11
0
 public static string Join(this Generic.IEnumerable <char> me)
 {
     System.Text.StringBuilder result = new System.Text.StringBuilder();
     foreach (char c in me)
     {
         result.Append(c);
     }
     return(result.ToString());
 }
        public static Dictionary <TKey, TSource> ToDictionary <TSource, TKey>(this Generic.IEnumerable <TSource> source, Func <TSource, TKey> keySelector, int capacity_ = 8)
        {
            var dict = new Dictionary <TKey, TSource>(capacity_);

            foreach (var elem in source)
            {
                dict.Add(keySelector(elem), elem);
            }
            return(dict);
        }
Example #13
0
 public static string Join(this Generic.IEnumerable <string> me)
 {
     System.Text.StringBuilder    result     = new System.Text.StringBuilder();
     Generic.IEnumerator <string> enumerator = me.GetEnumerator();
     while (enumerator.MoveNext())
     {
         result.Append(enumerator.Current);
     }
     return(result.ToString());
 }
Example #14
0
        public static T Last <T>(this Generic.IEnumerable <T> me)
        {
            T last = default(T);

            foreach (T item in me)
            {
                last = item;
            }
            return(last);
        }
Example #15
0
 public static Generic.IEnumerable <T> Filter <T>(this Generic.IEnumerable <T> me, Func <T, bool> predicate)
 {
     foreach (T element in me)
     {
         if (predicate(element))
         {
             yield return(element);
         }
     }
 }
Example #16
0
 public static Generic.IEnumerable <T> While <T>(this Generic.IEnumerable <T> me, Func <T, bool> predicate)
 {
     foreach (var item in me)
     {
         if (!predicate(item))
         {
             yield break;
         }
         yield return(item);
     }
 }
Example #17
0
 public static Generic.IEnumerable <T> Read <T>(this Generic.IEnumerable <T> me, int count)
 {
     if (count > 0)
     {
         var enumerator = me.GetEnumerator();
         do
         {
             yield return(enumerator.Current);
         }while (--count > 0 && enumerator.MoveNext());
     }
 }
Example #18
0
 public static IList <T> Add <T>(this IList <T> me, Generic.IEnumerable <T> items)
 {
     if (items.NotNull())
     {
         foreach (T item in items)
         {
             me.Add(item);
         }
     }
     return(me);
 }
Example #19
0
        public static Generic.IEnumerable <T> Skip <T>(this Generic.IEnumerable <T> me, int count)
        {
            var enumerator = me.GetEnumerator();

            while (count > 0 && enumerator.MoveNext())
            {
                count--;
            }
            while (enumerator.MoveNext())
            {
                yield return(enumerator.Current);
            }
        }
Example #20
0
        public static S Find <T, S>(this Generic.IEnumerable <T> me, Func <T, S> function)
        {
            S result = default(S);

            foreach (T element in me)
            {
                if ((result = function(element)) != null)
                {
                    break;
                }
            }
            return(result);
        }
Example #21
0
        public static T Find <T>(this Generic.IEnumerable <T> me, Func <T, bool> function)
        {
            T result = default(T);

            foreach (T element in me)
            {
                if (function(element))
                {
                    result = element;
                    break;
                }
            }
            return(result);
        }
Example #22
0
        public static bool All <T>(this Generic.IEnumerable <T> me, Func <T, bool> function)
        {
            bool result = true;

            foreach (T element in me)
            {
                if (!function(element))
                {
                    result = false;
                    break;
                }
            }
            return(result);
        }
Example #23
0
        public static bool Contains <T>(this Generic.IEnumerable <T> me, params T[] needles)
            where T : IEquatable <T>
        {
            bool result = false;

            foreach (T element in me)
            {
                if (needles.Contains(element))
                {
                    result = true;
                    break;
                }
            }
            return(result);
        }
Example #24
0
        public static T First <T>(this Generic.IEnumerable <T> me)
        {
            T result;

            if (me.NotNull())
            {
                using (Generic.IEnumerator <T> enumerator = me.GetEnumerator())
                    result = enumerator.MoveNext() ? enumerator.Current : default(T);
            }
            else
            {
                result = default(T);
            }
            return(result);
        }
Example #25
0
        public static T?FirstOrNull <T>(this Generic.IEnumerable <T> me)
            where T : struct
        {
            T?result;

            if (me.NotNull())
            {
                using (Generic.IEnumerator <T> enumerator = me.GetEnumerator())
                    result = enumerator.MoveNext() ? enumerator.Current : default(T);
            }
            else
            {
                result = null;
            }
            return(result);
        }
Example #26
0
 public static Generic.IEnumerable <T> Append <T>(this Generic.IEnumerable <T> me, Generic.IEnumerable <T> other)
 {
     if (me.NotNull())
     {
         foreach (T item in me)
         {
             yield return(item);
         }
     }
     if (other.NotNull())
     {
         foreach (T item in other)
         {
             yield return(item);
         }
     }
 }
Example #27
0
        public static bool All <T>(this Generic.IEnumerable <T> me, Func <T, bool, bool> function)
        {
            bool result = true;

            Generic.IEnumerator <T> enumerator = me.GetEnumerator();
            bool notLast = enumerator.MoveNext();

            while (notLast)
            {
                T current = enumerator.Current;
                if (!function(current, !(notLast = enumerator.MoveNext())))
                {
                    result = false;
                    break;
                }
            }
            return(result);
        }
Example #28
0
        public static int Index <T>(this Generic.IEnumerable <T> me, Func <T, bool> function)
        {
            int result = -1;
            int i      = 0;

            foreach (T element in me)
            {
                if (function(element))
                {
                    result = i;
                    break;
                }
                else
                {
                    i++;
                }
            }
            return(result);
        }
Example #29
0
 public static Generic.IEnumerable <char> Decode(this Generic.IEnumerable <byte> me, System.Text.Encoding encoding)
 {
     //if (encoding == System.Text.Encoding.UTF8)
     {
         byte[] buffer = new byte[6];
         int    length = 0;
         Generic.IEnumerator <byte> enumerator = me.GetEnumerator();
         while (enumerator.MoveNext())
         {
             buffer[0] = enumerator.Current;
             length    =
                 buffer[0] < 0x80 ? 1 :
                 buffer[0] < 0xc0 ? 0 :
                 buffer[0] < 0xe0 ? 2 :
                 buffer[0] < 0xf0 ? 3 :
                 buffer[0] < 0xf8 ? 4 :
                 buffer[0] < 0xfc ? 5 :
                 6;
             if (length > 0)
             {
                 int i = 1;
                 for (; i < length && enumerator.MoveNext(); i++)
                 {
                     buffer[i] = enumerator.Current;
                 }
                 if (length == 3 && buffer[0] == 0xef && buffer[1] == 0xbb && buffer[2] == 0xbf)
                 {
                     length = 0;                             // Skip "zero width no break space" (0xefbbbf)
                     //yield return ;
                 }
                 if (i == length)
                 {
                     foreach (char c in encoding.GetChars(buffer, 0, length))
                     {
                         yield return(c);
                     }
                 }
             }
         }
     }
 }
        /// <summary>
        /// Retrieving SharePoint list collection
        /// </summary>
        /// <returns> SharePoint list collection</returns>
        public async Task <Generic.List <List> > GetLists()
        {
            Generic.List <List> resultLists = new Generic.List <List>();
            IQueryable <List>   listsWithIncludedProperty = ClientObjectQueryableExtension.Include(context.Web.Lists,
                                                                                                   list => list.Id,
                                                                                                   list => list.Title,
                                                                                                   list => list.ItemCount,
                                                                                                   list => list.Fields.Include(f => f.Title, f => f.Indexed, f => f.InternalName));

            IQueryable <List> listCollection =
                listsWithIncludedProperty.Where(list => list.BaseType == BaseType.DocumentLibrary &&
                                                (list.BaseTemplate == (int)ListTemplateType.DocumentLibrary ||
                                                 list.BaseTemplate == (int)ListTemplateType.MySiteDocumentLibrary) &&
                                                list.Hidden == false);

            Generic.IEnumerable <List> lists = context.LoadQuery(listCollection);
            await ExecuteQuery();

            lists.ForEach(list => resultLists.Add(list));
            return(resultLists);
        }