Exemplo n.º 1
0
 public void ExcludeCards(Generic.IEnumerable <DominionCard> excludes)
 {
     foreach (var card in excludes)
     {
         this.excludes[card] = true;
     }
 }
Exemplo n.º 2
0
 public static void Apply <T>(this Generic.IEnumerable <T> me, Action <T> function)
 {
     foreach (T element in me)
     {
         function(element);
     }
 }
Exemplo n.º 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));
     }
 }
Exemplo n.º 4
0
 public List(int initialCapacity, Generic.IEnumerable <T> backend) :      this(initialCapacity)
 {
     foreach (var item in backend)
     {
         this.Add(item);
     }
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 8
0
Arquivo: Queue.cs Projeto: Spaxys/Kean
 public Queue(Generic.IEnumerable <T> data) :
     this()
 {
     foreach (var item in data)
     {
         this.Enqueue(item);
     }
 }
Exemplo n.º 9
0
 public Dictionary(Generic.IEnumerable <KeyValue <TKey, TValue> > data) :
     this()
 {
     foreach (var item in data)
     {
         this[item.Key] = item.Value;
     }
 }
Exemplo n.º 10
0
Arquivo: List.cs Projeto: Spaxys/Kean
 public List(Generic.IEnumerable <T> data) :
     this()
 {
     foreach (var item in data)
     {
         this.Add(item);
     }
 }
Exemplo n.º 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);
        }
Exemplo n.º 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());
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
         }
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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());
     }
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
         }
     }
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }