Пример #1
0
 public void Send(System.Collections.Generic.IEnumerable <SyslogMessage> messages, ISyslogMessageSerializer serializer)
 {
     // Slightly tricky, since we need to get the appName out of the first message before
     // looping, so we can't just use foreach(). Using an explicit iterator works, though.
     System.IntPtr ident = System.IntPtr.Zero;
     using (System.Collections.Generic.IEnumerator <SyslogMessage> iterator = messages.GetEnumerator())
     {
         try
         {
             if (iterator.MoveNext())
             {
                 SyslogMessage message = iterator.Current;
                 ident = MarshalIdent(message.AppName);
                 openlog(ident, (int)SyslogOptions.LogPid, CalculatePriorityValue(message.Facility, 0));
                 SendToSyslog(message, serializer);
             }
             while (iterator.MoveNext())
             {
                 SendToSyslog(iterator.Current, serializer);
             }
         }
         finally
         {
             closelog();
             DisposeOfIdent(ident);
         }
     }
 }
        private static void _FillArray <T>(T[] array, System.Collections.Generic.IEnumerable <T> items, System.Func <T> func_default)
        {
            if (array == null)
            {
                throw new System.ArgumentNullException("array");
            }

            if (items == null)
            {
                throw new System.ArgumentNullException("items");
            }

            if (func_default == null)
            {
                throw new System.ArgumentNullException("func_default");
            }

            using (var e = items.GetEnumerator())
            {
                for (int i = 0; i < array.Length; i++)
                {
                    bool move_ok = e.MoveNext();
                    if (move_ok)
                    {
                        array[i] = e.Current;
                    }
                    else
                    {
                        array[i] = func_default();
                    }
                }
            }
        }
        // the method is mostly copied from
        // https://github.com/dotnet/runtime/blob/c0840723b382bcfa67b35839af8572fcd38f1d13/src/libraries/System.Linq/src/System/Linq/Single.cs#L86
        public static TSource SingleOrDefault <TSource>(System.Collections.Generic.IEnumerable <TSource> source)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            if (source is System.Collections.Generic.IList <TSource> list)
            {
                switch (list.Count)
                {
                case 0:
                    return(default);

                case 1:
                    return(list[0]);
                }
            }
            else
            {
                using (System.Collections.Generic.IEnumerator <TSource> e = source.GetEnumerator())
                {
                    if (!e.MoveNext())
                    {
                        return(default);
Пример #4
0
        // Constructs a List, copying the contents of the given collection. The
        // size and capacity of the new list will both be equal to the size of the
        // given collection.
        //
        public List(System.Collections.Generic.IEnumerable <T> collection)
        {
            if (collection == null)
            {
                throw new Exception();
            }

            System.Collections.Generic.ICollection <T> c = collection as System.Collections.Generic.ICollection <T>;
            if (c != null)
            {
                int count = c.Count;
                _items = new T[count];
                c.CopyTo(_items, 0);
                _size = count;
            }
            else
            {
                _size  = 0;
                _items = new T[_defaultCapacity];

                using (System.Collections.Generic.IEnumerator <T> en = collection.GetEnumerator())
                {
                    while (en.MoveNext())
                    {
                        Add(en.Current);
                    }
                }
            }
        }
Пример #5
0
        public void AddRange(System.Collections.Generic.IEnumerable <T> collection)
        {
            if (collection == null)
            {
                throw new System.ArgumentNullException(nameof(collection));
            }

            if (collection is System.Collections.Generic.ICollection <T> c)
            {
                int count = c.Count;
                if (count > 0)
                {
                    var index = _size;
                    EnsureCapacity(count + index);
                    c.CopyTo(_items, index);
                    _size += count;
                }
            }
            else
            {
                // This enumerable could be empty.  Let Add allocate a new array, if needed.
                // Note it will also go to _defaultCapacity first, not 1, then 2, etc.

                using (System.Collections.Generic.IEnumerator <T> en = collection.GetEnumerator())
                {
                    while (en.MoveNext())
                    {
                        Add(en.Current);
                    }
                }
            }
        }
Пример #6
0
 static void SetObjRecursively(GameObject rootObj, Material mat)
 {
     if (null != rootObj.renderer)
     {
         Debug.Log(rootObj.renderer.name);
     }
     if (null != rootObj.particleSystem)
     {
         Debug.Log(rootObj.particleSystem.name);
         if (null != rootObj.particleSystem.renderer)
         {
             if ("Default-Particle (Instance)" == rootObj.particleSystem.renderer.material.name)
             {
                 rootObj.particleSystem.renderer.material = mat;
             }
         }
     }
     System.Collections.Generic.IEnumerable <GameObject> subObj = rootObj.GetDirectChildren();
     System.Collections.Generic.IEnumerator <GameObject> e      = subObj.GetEnumerator();
     if (null != rootObj)
     {
         while (e.MoveNext())
         {
             SetObjRecursively(e.Current, mat);
         }
     }
 }
Пример #7
0
        public static bool SequenceEquals <T>(this System.Collections.Generic.IEnumerable <T> left, System.Collections.Generic.IEnumerable <T> right)
        {
            if (object.ReferenceEquals(left, null))
            {
                return(object.ReferenceEquals(right, null));
            }

            try
            {
                using (var weird = left.GetEnumerator())
                {
                    using (var strnage = right.GetEnumerator())
                    {
                        while (weird.MoveNext())
                        {
                            if (strnage.MoveNext().Equals(false) ||
                                weird.Current.Equals(strnage.Current).Equals(false))
                            {
                                return(false);
                            }
                        }

                        return(true);
                    }
                }
            }
            catch
            {
                throw;
            }
        }
Пример #8
0
        public async System.Threading.Tasks.Task <string> GetPlaceID(string placeName)
        {
            string placeID = String.Empty;
            // request for place
            PlacesFindSearchRequest request = new PlacesFindSearchRequest();

            request.Key   = _googleAPIKey;
            request.Input = placeName;

            try
            {
                // response for place
                PlacesFindSearchResponse response = await GooglePlaces.FindSearch.QueryAsync(request);

                System.Collections.Generic.IEnumerable <Candidate> list       = response.Candidates;
                System.Collections.Generic.IEnumerator <Candidate> Enumerator = list.GetEnumerator();
                Candidate candidate = new Candidate();
                if (Enumerator.MoveNext())
                {
                    candidate = Enumerator.Current;
                }

                placeID = candidate.PlaceId;
            }
            catch (Exception e)
            {
                string message = e.Message;
            }

            return(placeID);
        }
Пример #9
0
 /// <summary>
 /// Instiate a new list using all members of the given IEnumerable
 /// </summary>
 /// <param name="initial">to use as initial members</param>
 public List(System.Collections.Generic.IEnumerable <T> initial) : base()
 {
     System.Collections.Generic.IEnumerator <T> enumerator = initial.GetEnumerator();
     while (enumerator.MoveNext())
     {
         Add(enumerator.Current);
     }
 }
Пример #10
0
 /// <summary>
 /// Tries to remove every given item
 /// </summary>
 /// <param name="toRemove">items to remove</param>
 public void RemoveAll(System.Collections.Generic.IEnumerable <T> toRemove)
 {
     System.Collections.Generic.IEnumerator <T> enumerator = toRemove.GetEnumerator();
     while (enumerator.MoveNext())
     {
         Remove(enumerator.Current);
     }
 }
Пример #11
0
 /// <summary>
 /// Tries to add every item
 /// </summary>
 /// <param name="toAdd">items to add</param>
 public void AddAll(System.Collections.Generic.IEnumerable <T> toAdd)
 {
     System.Collections.Generic.IEnumerator <T> enumerator = toAdd.GetEnumerator();
     while (enumerator.MoveNext())
     {
         Add(enumerator.Current);
     }
 }
Пример #12
0
        //public static implicit operator System.Collections.Generic.IEnumerable<System.Exception>(AggregateException aggregate){
        //    return aggregate.Aggregates;
        //}

        public System.Collections.Generic.IEnumerator <System.Exception> GetExceptions()
        {
            if (Common.IDisposedExtensions.IsNullOrDisposed(this))
            {
                throw new System.ObjectDisposedException("The instance is disposed.", this);
            }

            return(Aggregates.GetEnumerator());
        }
 public FilteredEnumerator(System.Collections.Generic.IEnumerable <T> enumerable, System.Func <T, bool> filter)
 {
     if (enumerable == null)
     {
         throw new System.ArgumentNullException();
     }
     this.enumerator = enumerable.GetEnumerator();
     this.filter     = filter; // could be null for unconditional enumeration.
 }
Пример #14
0
        public static System.Collections.Generic.IEnumerable <Video> Sort(this System.Collections.Generic.IEnumerable <Video> collectionToSort)
        {
            var readOnlySortCollection = collectionToSort.ToList().AsReadOnly();

            for (var video = collectionToSort.GetEnumerator(); video.MoveNext();)
            {
                video.Current.Position = readOnlySortCollection.IndexOf(video.Current);
            }
            return(collectionToSort);
        }
        /// <summary>
        /// Helper function for transforming Enumerable to an Array
        /// </summary>
        /// <param name="Enumerable">Enumerable object to transform into Array</param>
        /// <returns>Transformed Array from given Enumerable</returns>
        private static string[] EnumeratorToArray(System.Collections.Generic.IEnumerable <string> Enumerable)
        {
            System.Collections.Generic.List <string>        TempList   = new System.Collections.Generic.List <string>();
            System.Collections.Generic.IEnumerator <string> Enumerator = Enumerable.GetEnumerator();
            while (Enumerator.MoveNext())
            {
                TempList.Add(Enumerator.Current);
            }

            return(TempList.ToArray());
        }
Пример #16
0
        // Inserts the elements of the given collection at a given index. If
        // required, the capacity of the list is increased to twice the previous
        // capacity or the new size, whichever is larger.  Ranges may be added
        // to the end of the list by setting index to the List's size.
        //
        public void InsertRange(int index, System.Collections.Generic.IEnumerable <T> collection)
        {
            if (collection == null)
            {
                throw new Exception();
            }

            if ((uint)index > (uint)_size)
            {
                throw new Exception();
            }

            System.Collections.Generic.ICollection <T> c = collection as System.Collections.Generic.ICollection <T>;
            if (c != null)
            { // if collection is System.Collections.Generic.ICollection<T>
                int count = c.Count;
                if (count > 0)
                {
                    EnsureCapacity(_size + count);
                    if (index < _size)
                    {
                        Array.Copy(_items, index, _items, index + count, _size - index);
                    }

                    // If we're inserting a List into itself, we want to be able to deal with that.
                    if (this == c)
                    {
                        // Copy first part of _items to insert location
                        Array.Copy(_items, 0, _items, index, index);
                        // Copy last part of _items back to inserted location
                        Array.Copy(_items, index + count, _items, index * 2, _size - index);
                    }
                    else
                    {
                        T[] itemsToInsert = new T[count];
                        c.CopyTo(itemsToInsert, 0);
                        itemsToInsert.CopyTo(_items, index);
                    }
                    _size += count;
                }
            }
            else
            {
                using (System.Collections.Generic.IEnumerator <T> en = collection.GetEnumerator())
                {
                    while (en.MoveNext())
                    {
                        Insert(index++, en.Current);
                    }
                }
            }
            _version++;
        }
Пример #17
0
        //
        // Join
        //

        public static string Join(string separator, System.Collections.Generic.IEnumerable <string> values)
        {
            var @enum = values.GetEnumerator();

            return(system.text.StringBuilder.Join(separator, (ref bool done) =>
            {
                if (@enum.MoveNext())
                {
                    return @enum.Current;
                }
                done = true;
                return null;
            }));
        }
        static StackObject *GetEnumerator_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Collections.Generic.IEnumerable <System.Collections.Generic.KeyValuePair <System.String, ILRuntime.Runtime.Intepreter.ILTypeInstance> > instance_of_this_method = (System.Collections.Generic.IEnumerable <System.Collections.Generic.KeyValuePair <System.String, ILRuntime.Runtime.Intepreter.ILTypeInstance> >) typeof(System.Collections.Generic.IEnumerable <System.Collections.Generic.KeyValuePair <System.String, ILRuntime.Runtime.Intepreter.ILTypeInstance> >).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.GetEnumerator();

            return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method));
        }
Пример #19
0
        public void InsertRange(int index, System.Collections.Generic.IEnumerable <T> collection)
        {
            int count = Count;

            if (index > count || index < 0)
            {
                throw new System.ArgumentOutOfRangeException("index", index, "invalid index");
            }

            if (index == count)
            {
                var tailIter = collection.GetEnumerator();
                while (tailIter.MoveNext())
                {
                    AddLast(tailIter.Current);
                }
                tailIter.Dispose();
                return;
            }

            int i = 0;

            System.Collections.Generic.LinkedListNode <T> node = First;
            while (node != null && i++ < index)
            {
                node = node.Next;
            }

            var iter = collection.GetEnumerator();

            while (iter.MoveNext())
            {
                AddBefore(node, iter.Current);
            }
            iter.Dispose();
        }
Пример #20
0
        /// <summary>
        /// Determines whether a sequence contains any elements.
        /// </summary>
        /// <typeparam name="T">The type of the elements in the collection.</typeparam>
        /// <param name="collection">The collection.</param>
        /// <returns><c>true</c> if the collection contains at least one element; otherwise <c>false</c>.</returns>
        /// <exception cref="System.ArgumentNullException">collection is null.</exception>
        public static bool Any <T>(this System.Collections.Generic.IEnumerable <T> collection)
        {
            if (collection == null)
            {
                throw new ArgumentNullException("collection", "collection is null.");
            }

            using (var enumerator = collection.GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #21
0
        static StackObject *GetEnumerator_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Collections.Generic.IEnumerable <ETModel.Card> instance_of_this_method = (System.Collections.Generic.IEnumerable <ETModel.Card>) typeof(System.Collections.Generic.IEnumerable <ETModel.Card>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.GetEnumerator();

            object obj_result_of_this_method = result_of_this_method;

            if (obj_result_of_this_method is CrossBindingAdaptorType)
            {
                return(ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance));
            }
            return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method));
        }
Пример #22
0
        public HashCode AndEach <T>(System.Collections.Generic.IEnumerable <T> items)
        {
            // int hashCode = items.Select(GetHashCode).Aggregate(CombineHashCodes);
            int hashCode = 0;

            using (System.Collections.Generic.IEnumerator <T> e = items.GetEnumerator())
            {
                if (!e.MoveNext())
                {
                    throw new System.Exception("NoElements");
                }

                hashCode = GetHashCode(e.Current);

                while (e.MoveNext())
                {
                    hashCode = CombineHashCodes(hashCode, GetHashCode(e.Current));
                }
            } // End Using e

            return(new HashCode(CombineHashCodes(this.value, hashCode)));
        }
Пример #23
0
        /// <summary>
        /// Constructs a List, copying the contents of the given collection. The
        /// size and capacity of the new list will both be equal to the size of the
        /// given collection.
        /// </summary>
        /// <param name="collection">The collection whose elements are copied to the new list</param>
        /// <exception cref="System.ArgumentNullException">capacity is less than 0.</exception>
        public List(System.Collections.Generic.IEnumerable <T> collection)
        {
            if (collection == null)
            {
                throw new System.ArgumentNullException(nameof(collection));
            }

            if (collection is System.Collections.Generic.ICollection <T> c)
            {
                int count = c.Count;
                if (count == 0)
                {
                    _items = _emptyArray;
                }
                else
                {
                    _items = new T[count];
                    c.CopyTo(_items, 0);
                    _size = count;
                }
            }
            else
            {
                _size  = 0;
                _items = _emptyArray;
                // This enumerable could be empty.  Let Add allocate a new array, if needed.
                // Note it will also go to _defaultCapacity first, not 1, then 2, etc.

                using (var en = collection.GetEnumerator())
                {
                    while (en.MoveNext())
                    {
                        Add(en.Current);
                    }
                }
            }
        }
        private static Boolean CleanArray(ref Object obj)
        {
            Boolean result = false;

            if (obj == null)
            {
                return(false);
            }
            if (obj.GetType().GetProperties().Length <= 0)
            {
                return(false);
            }
            // if (obj.GetType() == typeof(String)) return false;
            else
            {
                if (typeof(IEnumerable).IsAssignableFrom(obj.GetType()))
                {
                    if ((obj.GetType().IsGenericType) || (obj.GetType().IsArray))
                    {
                        System.Collections.Generic.IEnumerable <Object> listObj = (System.Collections.Generic.IEnumerable <Object>)obj;

                        if (listObj.GetEnumerator().MoveNext())
                        {
                            return(false);
                        }
                        else
                        {
                            obj = null;
                            return(true);
                        }
                    }
                }

                else
                {
                    MemberInfo[] mis = obj.GetType().GetMembers();
                    for (int j = 0; j < mis.Length; j++)
                    {
                        MemberInfo pi = obj.GetType().GetMember(mis[j].Name)[0];

                        if (pi.MemberType == MemberTypes.Property)
                        {
                            try
                            {
                                Object subObj = ((PropertyInfo)pi).GetValue(obj, null);
                                if (subObj != null)
                                {
                                    if (subObj.GetType() != obj.GetType())
                                    {
                                        if (CleanArray(ref subObj))
                                        {
                                            ((PropertyInfo)pi).SetValue(obj, subObj, null);
                                            result = true;
                                        }
                                    }
                                }
                            }
                            catch (Exception e) { Console.WriteLine(e.Message); };
                        }
                    }

                    /*
                     * PropertyInfo[] pros = obj.GetType().GetProperties();
                     * for (int i = 0; i < pros.Length; i++)
                     * {
                     *  for (int j = 0; j < pros[i].GetAccessors().Length; j++)
                     *  {
                     *      MethodInfo mi = pros[i].GetAccessors()[j];
                     *      Object subObj= mi.Invoke(obj,null);
                     *      CleanArray(subObj);
                     *  }
                     * }
                     */
                }
            }
            return(result);
        }
            public override void Execute(TriggerBase trigger)
            {
                if (trigger.IsArgumentDefined("target"))
                {
                    Character character = trigger.Get <Character>("target");
                    System.Collections.Generic.IEnumerable <BasePlayerItem> itemsByPattern = Singleton <ItemManager> .Instance.GetItemsByPattern(trigger.Get <string>("pattern"), character.Inventory);

                    using (System.Collections.Generic.IEnumerator <BasePlayerItem> enumerator = itemsByPattern.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            BasePlayerItem current = enumerator.Current;
                            trigger.Reply("'{0}'({1}) Amount:{2} Guid:{3}", new object[]
                            {
                                current.Template.Name,
                                current.Template.Id,
                                current.Stack,
                                current.Guid
                            });
                        }
                        return;
                    }
                }
                System.Collections.Generic.IEnumerable <ItemTemplate> itemsByPattern2 = Singleton <ItemManager> .Instance.GetItemsByPattern(trigger.Get <string>("pattern"));

                int num  = trigger.Get <int>("page") * ItemRemoveCommand.ItemListCommand.LimitItemList;
                int num2 = 0;

                System.Collections.Generic.IEnumerator <ItemTemplate> enumerator2 = itemsByPattern2.GetEnumerator();
                int num3 = 0;

                while (enumerator2.MoveNext())
                {
                    if (num3 >= num)
                    {
                        ItemTemplate current2 = enumerator2.Current;
                        if (num2 < ItemRemoveCommand.ItemListCommand.LimitItemList)
                        {
                            trigger.Reply("'{0}'({1})", new object[]
                            {
                                current2.Name,
                                current2.Id
                            });
                            num2++;
                        }
                        else
                        {
                            trigger.Reply("... (limit reached : {0})", new object[]
                            {
                                ItemRemoveCommand.ItemListCommand.LimitItemList
                            });
                            if (num2 == 0)
                            {
                                trigger.Reply("No results");
                                return;
                            }
                            return;
                        }
                    }
                    num3++;
                }
            }
 //
 // IEnumerable<object> methods. We need this because System.Array implement this (implicitly) if it is castable to object[]
 //
 System.Collections.Generic.IEnumerator <object> System.Collections.Generic.IEnumerable <object> .GetEnumerator()
 {
     return(_enumerableOfObject.GetEnumerator());
 }
 public static System.Collections.Generic.List <ServiceStack.Translators.Generator.Tests.Support.DataContract.Customer> ToDtoCustomers(this System.Collections.Generic.IEnumerable <ServiceStack.Translators.Generator.Tests.Support.Model.Customer> from)
 {
     if ((from == null))
     {
         return(null);
     }
     System.Collections.Generic.List <ServiceStack.Translators.Generator.Tests.Support.DataContract.Customer> to = new System.Collections.Generic.List <ServiceStack.Translators.Generator.Tests.Support.DataContract.Customer>();
     for (System.Collections.Generic.IEnumerator <ServiceStack.Translators.Generator.Tests.Support.Model.Customer> iter = from.GetEnumerator(); iter.MoveNext();
          )
     {
         ServiceStack.Translators.Generator.Tests.Support.Model.Customer item = iter.Current;
         to.Add(item.ToDtoCustomer());
     }
     return(to);
 }
Пример #28
0
        /// <summary>Compares the contents of a <see cref="IEnumerable{T}"/>
        /// implementation to another one to determine equality.</summary>
        /// <remarks>Thinking of the <see cref="IEnumerable{T}"/> implementation as
        /// a string with any number of characters, the algorithm checks
        /// each item in each list.  If any item of the list is not equal (or
        /// one list contains all the elements of another list), then that list
        /// element is compared to the other list element to see which
        /// list is greater.</remarks>
        /// <param name="x">The <see cref="IEnumerable{T}"/> implementation
        /// that is considered the left hand side.</param>
        /// <param name="y">The <see cref="IEnumerable{T}"/> implementation
        /// that is considered the right hand side.</param>
        /// <returns>True if the items are equal, false otherwise.</returns>
        private static bool Equals(System.Collections.Generic.IEnumerable <T> x,
                                   System.Collections.Generic.IEnumerable <T> y)
        {
            // If x and y are null, then return true, they are the same.
            if (x == null && y == null)
            {
                // They are the same, return 0.
                return(true);
            }

            // If one is null, then return a value based on whether or not
            // one is null or not.
            if (x == null || y == null)
            {
                // Return false, one is null, the other is not.
                return(false);
            }

            // Check to see if the counts on the IEnumerable implementations are equal.
            // This is a shortcut, if they are not equal, then the lists are not equal.
            // If the result is indeterminate, then get out.
            bool?enumerableCountsEqual = EnumerableCountsEqual(x, y);

            // If the enumerable counts have been able to be calculated (indicated by
            // a non-null value) and it is false, then no need to iterate through the items.
            if (enumerableCountsEqual != null && !enumerableCountsEqual.Value)
            {
                // The sequences are not equal.
                return(false);
            }

            // The counts of the items in the enumerations are equal, or indeterminate
            // so a full iteration needs to be made to compare each item.
            // Get the default comparer for T first.
            System.Collections.Generic.EqualityComparer <T> defaultComparer =
                System.Collections.Generic.EqualityComparer <T> .Default;

            // Get the enumerator for y.
            System.Collections.Generic.IEnumerator <T> otherEnumerator = y.GetEnumerator();

            // Call Dispose on IDisposable if there is an implementation on the
            // IEnumerator<T> returned by a call to y.GetEnumerator().
            using (otherEnumerator as IDisposable)
            {
                // Cycle through the items in this list.
                foreach (T item in x)
                {
                    // If there isn't an item to get, then this has more
                    // items than that, they are not equal.
                    if (!otherEnumerator.MoveNext())
                    {
                        // Return false.
                        return(false);
                    }

                    // Perform a comparison.  Must check this on the left hand side
                    // and that on the right hand side.
                    bool comparison = defaultComparer.Equals(item, otherEnumerator.Current);

                    // If the value is false, return false.
                    if (!comparison)
                    {
                        // Return the value.
                        return(comparison);
                    }
                }

                // If there are no more items, then return true, the sequences
                // are equal.
                if (!otherEnumerator.MoveNext())
                {
                    // The sequences are equal.
                    return(true);
                }

                // The other sequence has more items than this one, return
                // false, these are not equal.
                return(false);
            }
        }
Пример #29
0
 public static System.Collections.Generic.List <ServiceStack.Translators.Generator.Tests.Support.Model.Address> ToDomainModelAddresss(this System.Collections.Generic.IEnumerable <ServiceStack.Translators.Generator.Tests.Support.DataContract.Address> from)
 {
     if ((from == null))
     {
         return(null);
     }
     System.Collections.Generic.List <ServiceStack.Translators.Generator.Tests.Support.Model.Address> to = new System.Collections.Generic.List <ServiceStack.Translators.Generator.Tests.Support.Model.Address>();
     for (System.Collections.Generic.IEnumerator <ServiceStack.Translators.Generator.Tests.Support.DataContract.Address> iter = from.GetEnumerator(); iter.MoveNext();
          )
     {
         ServiceStack.Translators.Generator.Tests.Support.DataContract.Address item = iter.Current;
         if ((item != null))
         {
             to.Add(item.ToDomainModelAddress());
         }
     }
     return(to);
 }
 /// <summary>
 /// Takes an IEnumerable-char input, and calls Append(...) on each character, appending a child element for each character to a root xml document.
 /// </summary>
 /// <param name="input"></param>
 public void Append(System.Collections.Generic.IEnumerable <char> input)
 {
     this.Append(input.GetEnumerator());
 }