Example #1
0
        /// <summary>
        /// Implements __contains__ for types implementing IEnumerable
        /// </summary>
        public static bool ContainsMethodIEnumerator(CodeContext /*!*/ context, IEnumerator enumerator, object value)
        {
            while (enumerator.MoveNext())
            {
                if (PythonOps.IsOrEqualsRetBool(context, enumerator.Current, value))
                {
                    return(true);
                }
            }

            return(false);
        }
Example #2
0
        /// <summary>
        /// Implements __contains__ for types implementing IEnumerable of T.
        /// </summary>
        public static bool ContainsGenericMethod <T>(CodeContext /*!*/ context, IEnumerable <T> enumerable, T value)
        {
            foreach (T item in enumerable)
            {
                if (PythonOps.IsOrEqualsRetBool(context, item, value))
                {
                    return(true);
                }
            }

            return(false);
        }
Example #3
0
        /// <summary>
        /// Implements __contains__ for types implementing IEnumerable
        /// </summary>
        public static bool ContainsMethod(CodeContext /*!*/ context, IEnumerable enumerable, object value)
        {
            IEnumerator ie = enumerable.GetEnumerator();

            while (ie.MoveNext())
            {
                if (PythonOps.IsOrEqualsRetBool(context, ie.Current, value))
                {
                    return(true);
                }
            }

            return(false);
        }