System.Collections.IEnumerator.MoveNext()

Here are the examples of the csharp api System.Collections.IEnumerator.MoveNext() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

3655 Examples 7

19 Source : Ext.cs
with GNU General Public License v3.0
from 1330-Studios

public static Il2CppReferenceArray<T> Add<T>(this Il2CppReferenceArray<T> reference, IEnumerable<T> enumerable) where T : Model {
            var bases = new List<T>();
            foreach (var tmp in reference)
                bases.Add(tmp);

            var enumerator = enumerable.GetEnumerator();
            while (enumerator.MoveNext()) bases.Add(enumerator.Current);

            return new(bases.ToArray());
        }

19 Source : Ext.cs
with GNU General Public License v3.0
from 1330-Studios

public static Il2CppSystem.Collections.Generic.IEnumerable<C> SelectI<T, R, C>(this IEnumerable<T> enumerable, Func<T, R> predicate) where R : Model where C : Model {
            var bases = new Il2CppSystem.Collections.Generic.List<C>();
            var enumerator = enumerable.GetEnumerator();
            while (enumerator.MoveNext())
                bases.Add(predicate(enumerator.Current).Cast<C>());
            return bases.Cast<Il2CppSystem.Collections.Generic.IEnumerable<C>>();
        }

19 Source : IndexOfObjectsInputSource.cs
with MIT License
from 1996v

public bool MoveNext()
        {
            return entries.MoveNext();
        }

19 Source : PanelManager.cs
with MIT License
from 404Lcc

public int ClearOpenPanels()
        {
            int number = 0;
            IDictionaryEnumerator enumerator = panels.GetEnumerator();
            while (enumerator.MoveNext())
            {
                Panel panel = (Panel)enumerator.Value;
                if (panel.State == PanelState.Open)
                {
                    ClearPanel(panel.Type);
                    number++;
                }
            }
            return number;
        }

19 Source : JsonData.cs
with MIT License
from 404Lcc

public bool MoveNext ()
        {
            return list_enumerator.MoveNext ();
        }

19 Source : Param_Cloud.cs
with GNU Lesser General Public License v3.0
from 9and3

public void BakeGeometry(RhinoDoc doc, ObjectAttributes att, List<Guid> obj_ids) {
            Guid guid = new Guid();
            IEnumerator enumerator = null;
            if (att == null) {
                att = doc.CreateDefaultAttributes();
            }
            try {
                enumerator = this.m_data.GetEnumerator();
                while (enumerator.MoveNext()) {
                    IGH_BakeAwareData current = (IGH_BakeAwareData)enumerator.Current;
                    if (current == null || !current.BakeGeometry(doc, att, out guid)) {
                        continue;
                    }
                    obj_ids.Add(guid);
                }
            } finally {
                if (enumerator is IDisposable) {
                    (enumerator as IDisposable).Dispose();
                }
            }
        }

19 Source : GH_Cloud.cs
with GNU Lesser General Public License v3.0
from 9and3

public override IGH_GeometricGoo Transform(Transform xform) {
            IGH_GeometricGoo gHGeometricGoo;
            IEnumerator<PointCloudItem> enumerator = null;
            if (this.IsValid) {
                this.m_value.Transform(xform);
                if (this.m_value.ContainsNormals) {
                    try {
                        enumerator = this.m_value.GetEnumerator();
                        while (enumerator.MoveNext()) {
                            PointCloudItem current = enumerator.Current;
                            Vector3d normal = current.Normal;
                            normal.Transform(xform);
                            current.Normal=(normal);
                        }
                    } finally {
                        if (enumerator != null) {
                            enumerator.Dispose();
                        }
                    }
                }
                this.ReferenceID = Guid.Empty;
                this.ScanPos.Transform(xform);
                gHGeometricGoo = this;
            } else {
                gHGeometricGoo = null;
            }
            return gHGeometricGoo;
        }

19 Source : WorkerCoroutine.cs
with Apache License 2.0
from A7ocin

public bool Work()
	    {
            TimeHint = 0;
	        while (true)
	        {
	            // process nested work jobs first
	            if (subWorker != null)
	            {
	                if (subWorker.Work())
	                {
	                    subWorker = null;
	                }
	                else
	                {
	                    // subWorker requested pause
                        TimeHint = subWorker.TimeHint;
                        if (lastWorker == subWorker)
                        {
                            lastWorkerCount++;
                        }
                        else
                        {
                            lastWorkerCount = 1;
                        }
                        lastWorker = subWorker;
                        return false;
	                }
	            }

	            if (workerInstance == null)
	            {
	                workerInstance = workerMethod();
	                Start();
	            }

                bool done;
                try
                {
                    done = !workerInstance.MoveNext(); // we're done when we can't get next Enumerator element
                }
                catch(Exception e)
                {
                    throw new Exception("Exception in WorkerCoroutine: "+this, e);
                }
	            if (done)
	            {
	                // we truly are done
	                Stop();
	                workerInstance = null;
	                return true;
	            }
	            else
	            {
	                subWorker = workerInstance.Current as WorkerCoroutine;
	                if (subWorker == null)
	                {
                        if (lastWorker == this)
                        {
                            lastWorkerCount++;
                        }
                        else
                        {
                            lastWorkerCount = 1;
                        }
                        lastWorker = this;

                        // returned null take a break
                        if (workerInstance.Current is int)
                        {
                            TimeHint = (int)workerInstance.Current;
                        }
                        return false;
	                }

	                // returned a subWorker, no time to rest
	                continue;
	            }
	        }
	    }

19 Source : SortedObservableCollectionTests.cs
with Microsoft Public License
from AArnott

[Fact]
	public void GetEnumerator_NonGenericInterface()
	{
		this.collection.Add(3);
		this.collection.Add(5);
		IEnumerable enumerable = this.collection;
		IEnumerator enumerator = enumerable.GetEnumerator();
		replacedert.True(enumerator.MoveNext());
		replacedert.Equal(5, enumerator.Current);
		replacedert.True(enumerator.MoveNext());
		replacedert.Equal(3, enumerator.Current);
		replacedert.False(enumerator.MoveNext());
	}

19 Source : EnumerableExtensions.cs
with Apache License 2.0
from abist-co-ltd

public static T MaxOrDefault<T>(this IEnumerable<T> items, IComparer<T> comparer = null)
        {
            if (items == null) { throw new ArgumentNullException("items"); }
            comparer = comparer ?? Comparer<T>.Default;

            using (var enumerator = items.GetEnumerator())
            {
                if (!enumerator.MoveNext())
                {
                    return default(T);
                }

                var max = enumerator.Current;
                while (enumerator.MoveNext())
                {
                    if (comparer.Compare(max, enumerator.Current) < 0)
                    {
                        max = enumerator.Current;
                    }
                }
                return max;
            }
        }

19 Source : AwaiterExtensions.cs
with Apache License 2.0
from abist-co-ltd

public IEnumerator Run()
            {
                while (true)
                {
                    var topWorker = processStack.Peek();

                    bool isDone;

                    try
                    {
                        isDone = !topWorker.MoveNext();
                    }
                    catch (Exception e)
                    {
                        // The IEnumerators we have in the process stack do not tell us the
                        // actual names of the coroutine methods but it does tell us the objects
                        // that the IEnumerators are replacedociated with, so we can at least try
                        // adding that to the exception output
                        var objectTrace = GenerateObjectTrace(processStack);
                        awaiter.Complete(default(T), objectTrace.Any() ? new Exception(GenerateObjectTraceMessage(objectTrace), e) : e);

                        yield break;
                    }

                    if (isDone)
                    {
                        processStack.Pop();

                        if (processStack.Count == 0)
                        {
                            awaiter.Complete((T)topWorker.Current, null);
                            yield break;
                        }
                    }

                    // We could just yield return nested IEnumerator's here but we choose to do
                    // our own handling here so that we can catch exceptions in nested coroutines
                    // instead of just top level coroutine
                    var item = topWorker.Current as IEnumerator;
                    if (item != null)
                    {
                        processStack.Push(item);
                    }
                    else
                    {
                        // Return the current value to the unity engine so it can handle things like
                        // WaitForSeconds, WaitToEndOfFrame, etc.
                        yield return topWorker.Current;
                    }
                }
            }

19 Source : OVRPlatformTool.cs
with MIT License
from absurd-joy

void Update()
			{
				if (!routine.MoveNext())
				{
					Stop();
				}
			}

19 Source : OVRLipSyncTool.cs
with MIT License
from absurd-joy

static void Update()
    {
        if (processor != null)
        {
            processor.MoveNext();
        }
    }

19 Source : EnumerableExtensions.cs
with MIT License
from actions

public static IEnumerable<T> Merge<T>(
            this IEnumerable<T> first,
            IEnumerable<T> second,
            Func<T, T, int> comparer)
        {
            ArgumentUtility.CheckForNull(first, nameof(first));
            ArgumentUtility.CheckForNull(second, nameof(second));
            ArgumentUtility.CheckForNull(comparer, nameof(comparer));

            using (IEnumerator<T> e1 = first.GetEnumerator())
            using (IEnumerator<T> e2 = second.GetEnumerator())
            {
                bool e1Valid = e1.MoveNext();
                bool e2Valid = e2.MoveNext();

                while (e1Valid && e2Valid)
                {
                    if (comparer(e1.Current, e2.Current) <= 0)
                    {
                        yield return e1.Current;

                        e1Valid = e1.MoveNext();
                    }
                    else
                    {
                        yield return e2.Current;

                        e2Valid = e2.MoveNext();
                    }
                }

                while (e1Valid)
                {
                    yield return e1.Current;

                    e1Valid = e1.MoveNext();
                }

                while (e2Valid)
                {
                    yield return e2.Current;

                    e2Valid = e2.MoveNext();
                }
            }
        }

19 Source : EnumerableExtensions.cs
with MIT License
from actions

public static IEnumerable<T> MergeDistinct<T>(
            this IEnumerable<T> first,
            IEnumerable<T> second,
            Func<T, T, int> comparer)
        {
            ArgumentUtility.CheckForNull(first, nameof(first));
            ArgumentUtility.CheckForNull(second, nameof(second));
            ArgumentUtility.CheckForNull(comparer, nameof(comparer));

            using (IEnumerator<T> e1 = first.GetEnumerator())
            using (IEnumerator<T> e2 = second.GetEnumerator())
            {
                bool e1Valid = e1.MoveNext();
                bool e2Valid = e2.MoveNext();

                while (e1Valid && e2Valid)
                {
                    if (comparer(e1.Current, e2.Current) < 0)
                    {
                        yield return e1.Current;

                        e1Valid = e1.MoveNext();
                    }
                    else if (comparer(e1.Current, e2.Current) > 0)
                    {
                        yield return e2.Current;

                        e2Valid = e2.MoveNext();
                    }
                    else
                    {
                        yield return e1.Current;

                        e1Valid = e1.MoveNext();
                        e2Valid = e2.MoveNext();
                    }
                }

                while (e1Valid)
                {
                    yield return e1.Current;

                    e1Valid = e1.MoveNext();
                }

                while (e2Valid)
                {
                    yield return e2.Current;

                    e2Valid = e2.MoveNext();
                }
            }
        }

19 Source : ToJson.cs
with MIT License
from actions

public Boolean MoveNext()
            {
                if (m_enumerator.MoveNext())
                {
                    m_current = EvaluationResult.CreateIntermediateResult(m_context, m_enumerator.Current);
                    m_index++;
                    return true;
                }
                else
                {
                    m_current = null;
                    return false;
                }
            }

19 Source : ToJson.cs
with MIT License
from actions

public Boolean MoveNext()
            {
                if (m_enumerator.MoveNext())
                {
                    var current = (KeyValuePair<String, Object>)m_enumerator.Current;
                    var key = EvaluationResult.CreateIntermediateResult(m_context, current.Key);
                    var value = EvaluationResult.CreateIntermediateResult(m_context, current.Value);
                    m_current = new KeyValuePair<EvaluationResult, EvaluationResult>(key, value);
                    m_index++;
                    return true;
                }
                else
                {
                    m_current = default(KeyValuePair<EvaluationResult, EvaluationResult>);
                    return false;
                }
            }

19 Source : JsonObjectReader.cs
with MIT License
from actions

public Boolean AllowLiteral(out LiteralToken literal)
        {
            var current = m_enumerator.Current;
            switch (current.Type)
            {
                case ParseEventType.Null:
                    literal = new NullToken(m_fileId, current.Line, current.Column);
                    m_enumerator.MoveNext();
                    return true;

                case ParseEventType.Boolean:
                    literal = new BooleanToken(m_fileId, current.Line, current.Column, (Boolean)current.Value);
                    m_enumerator.MoveNext();
                    return true;

                case ParseEventType.Number:
                    literal = new NumberToken(m_fileId, current.Line, current.Column, (Double)current.Value);
                    m_enumerator.MoveNext();
                    return true;

                case ParseEventType.String:
                    literal = new StringToken(m_fileId, current.Line, current.Column, (String)current.Value);
                    m_enumerator.MoveNext();
                    return true;
            }

            literal = null;
            return false;
        }

19 Source : JsonObjectReader.cs
with MIT License
from actions

public Boolean AllowSequenceStart(out SequenceToken sequence)
        {
            var current = m_enumerator.Current;
            if (current.Type == ParseEventType.SequenceStart)
            {
                sequence = new SequenceToken(m_fileId, current.Line, current.Column);
                m_enumerator.MoveNext();
                return true;
            }

            sequence = null;
            return false;
        }

19 Source : JsonObjectReader.cs
with MIT License
from actions

public Boolean AllowSequenceEnd()
        {
            if (m_enumerator.Current.Type == ParseEventType.SequenceEnd)
            {
                m_enumerator.MoveNext();
                return true;
            }

            return false;
        }

19 Source : JsonObjectReader.cs
with MIT License
from actions

public Boolean AllowMappingStart(out MappingToken mapping)
        {
            var current = m_enumerator.Current;
            if (current.Type == ParseEventType.MappingStart)
            {
                mapping = new MappingToken(m_fileId, current.Line, current.Column);
                m_enumerator.MoveNext();
                return true;
            }

            mapping = null;
            return false;
        }

19 Source : JsonObjectReader.cs
with MIT License
from actions

public Boolean AllowMappingEnd()
        {
            if (m_enumerator.Current.Type == ParseEventType.MappingEnd)
            {
                m_enumerator.MoveNext();
                return true;
            }

            return false;
        }

19 Source : JsonObjectReader.cs
with MIT License
from actions

public void ValidateEnd()
        {
            if (m_enumerator.Current.Type == ParseEventType.DoreplacedentEnd)
            {
                m_enumerator.MoveNext();
                return;
            }

            throw new InvalidOperationException("Expected end of reader");
        }

19 Source : JsonObjectReader.cs
with MIT License
from actions

public void ValidateStart()
        {
            if (m_enumerator.Current.Type == ParseEventType.DoreplacedentStart)
            {
                m_enumerator.MoveNext();
                return;
            }

            throw new InvalidOperationException("Expected start of reader");
        }

19 Source : PropertiesCollection.cs
with MIT License
from actions

public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
            {
                if (reader.TokenType == JsonToken.StartObject)
                {
                    JObject valueInfo = serializer.Deserialize<JObject>(reader);
                    if (!valueInfo.TryGetValue(TypePropertyName, out JToken typeToken) ||
                        !valueInfo.TryGetValue(ValuePropertyName, out JToken valueToken))
                    {
                        // The following block is for compatability with old code behavior.
                        // The old code blindly took the first argument add treated it as the $type string,
                        // It blindly took the second argument and treated it as the $value object.
                        IEnumerator<JToken> tokenEnumerator = valueInfo.Values().GetEnumerator();
                        if (tokenEnumerator.MoveNext())
                        {
                            typeToken = tokenEnumerator.Current;
                            if (tokenEnumerator.MoveNext())
                            {
                                valueToken = tokenEnumerator.Current;
                            }
                            else
                            {
                                throw new InvalidOperationException(WebApiResources.DeserializationCorrupt());
                            }
                        }
                        else
                        {
                            throw new InvalidOperationException(WebApiResources.DeserializationCorrupt());
                        }
                    }

                    string typeToCreate = typeToken.ToObject<string>();

                    //make sure the string is a valid type,
                    //an arbitrary type string with nested generics could overflow the
                    //stack for a DOS.
                    if (!PropertyValidation.TryGetValidType(typeToCreate, out Type type))
                    {
                        throw new InvalidOperationException(WebApiResources.DeserializationCorrupt());
                    }

                    //deserialize the type
                    return valueToken.ToObject(type);
                }
                else if (reader.TokenType == JsonToken.Boolean ||
                         reader.TokenType == JsonToken.Bytes ||
                         reader.TokenType == JsonToken.Date ||
                         reader.TokenType == JsonToken.Float ||
                         reader.TokenType == JsonToken.Integer ||
                         reader.TokenType == JsonToken.String)
                {
                    // Allow the JSON to simply specify "name": value syntax if type information is not necessary.
                    return serializer.Deserialize(reader);
                }
                else if (reader.TokenType == JsonToken.Null)
                {
                    return null;
                }
                else
                {
                    throw new InvalidOperationException(WebApiResources.DeserializationCorrupt());
                }
            }

19 Source : BinaryOperatorExpression.g.cs
with MIT License
from Actipro

protected override IEnumerator<IAstNode> GetChildrenEnumerator() {
            IEnumerator<IAstNode> baseEnumerator = base.GetChildrenEnumerator();
            if ((baseEnumerator != null)) {
				while (baseEnumerator.MoveNext())
					yield return baseEnumerator.Current;
            }
            if ((this.leftExpressionValue != null)) {
				yield return this.leftExpressionValue;
            }
            if ((this.rightExpressionValue != null)) {
				yield return this.rightExpressionValue;
            }
        }

19 Source : ParenthesizedExpression.g.cs
with MIT License
from Actipro

protected override IEnumerator<IAstNode> GetChildrenEnumerator() {
            IEnumerator<IAstNode> baseEnumerator = base.GetChildrenEnumerator();
            if ((baseEnumerator != null)) {
				while (baseEnumerator.MoveNext())
					yield return baseEnumerator.Current;
            }
            if ((this.childExpressionValue != null)) {
				yield return this.childExpressionValue;
            }
        }

19 Source : MCompositeDetails.cs
with GNU Affero General Public License v3.0
from active-logic

status Ordered(){
        ι = ι ?? tasks.GetEnumerator();
        if(task == null){
            if(ι.MoveNext()) task = ι.Current;
            else return current;
        }
        current = task();
        if(current == key){
            if(ι.MoveNext()) { task = ι.Current; return cont; }
            else             { task = null;                   }
        }
        return current;
    }

19 Source : AssignmentStatement.g.cs
with MIT License
from Actipro

protected override IEnumerator<IAstNode> GetChildrenEnumerator() {
            IEnumerator<IAstNode> baseEnumerator = base.GetChildrenEnumerator();
            if ((baseEnumerator != null)) {
				while (baseEnumerator.MoveNext())
					yield return baseEnumerator.Current;
            }
            if ((this.expressionValue != null)) {
				yield return this.expressionValue;
            }
        }

19 Source : BlockStatement.g.cs
with MIT License
from Actipro

protected override IEnumerator<IAstNode> GetChildrenEnumerator() {
            IEnumerator<IAstNode> baseEnumerator = base.GetChildrenEnumerator();
            if ((baseEnumerator != null)) {
				while (baseEnumerator.MoveNext())
					yield return baseEnumerator.Current;
            }
            if ((this.childStatementsValue != null)) {
				foreach (IAstNode childStatementsValueItem in this.childStatementsValue)
					if (childStatementsValueItem != null) yield return childStatementsValueItem;
            }
        }

19 Source : CompilationUnit.g.cs
with MIT License
from Actipro

protected override IEnumerator<IAstNode> GetChildrenEnumerator() {
            IEnumerator<IAstNode> baseEnumerator = base.GetChildrenEnumerator();
            if ((baseEnumerator != null)) {
				while (baseEnumerator.MoveNext())
					yield return baseEnumerator.Current;
            }
            if ((this.membersValue != null)) {
				foreach (IAstNode membersValueItem in this.membersValue)
					if (membersValueItem != null) yield return membersValueItem;
            }
        }

19 Source : FunctionAccessExpression.g.cs
with MIT License
from Actipro

protected override IEnumerator<IAstNode> GetChildrenEnumerator() {
            IEnumerator<IAstNode> baseEnumerator = base.GetChildrenEnumerator();
            if ((baseEnumerator != null)) {
				while (baseEnumerator.MoveNext())
					yield return baseEnumerator.Current;
            }
            if ((this.argumentsValue != null)) {
				foreach (IAstNode argumentsValueItem in this.argumentsValue)
					if (argumentsValueItem != null) yield return argumentsValueItem;
            }
        }

19 Source : FunctionDeclaration.g.cs
with MIT License
from Actipro

protected override IEnumerator<IAstNode> GetChildrenEnumerator() {
            IEnumerator<IAstNode> baseEnumerator = base.GetChildrenEnumerator();
            if ((baseEnumerator != null)) {
				while (baseEnumerator.MoveNext())
					yield return baseEnumerator.Current;
            }
            if ((this.bodyValue != null)) {
				yield return this.bodyValue;
            }
        }

19 Source : EnumerableExtraExtensions.cs
with GNU General Public License v3.0
from Acumatica

public static bool SequenceEqual<T>(this IEnumerable<T> first, IEnumerable<T> second, Func<T, T, bool> comparer)
		{
			Debug.replacedert(comparer != null);

			if (first == second)
			{
				return true;
			}

			if (first == null || second == null)
			{
				return false;
			}

			using (var enumerator = first.GetEnumerator())
			using (var enumerator2 = second.GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					if (!enumerator2.MoveNext() || !comparer(enumerator.Current, enumerator2.Current))
					{
						return false;
					}
				}

				if (enumerator2.MoveNext())
				{
					return false;
				}
			}

			return true;
		}

19 Source : VisualComponentsOfCollection.cs
with GNU General Public License v3.0
from Adam-Wilkinson

private int GetIndexOf(object value)
        {
            IEnumerator<IVisualNodeComponent> enumer = GetEnumerator();
            for (int i = 0; i < Count; i++)
            {
                enumer.MoveNext();
                if (enumer.Current == value)
                {
                    return i;
                }
            }

            return -1;
        }

19 Source : VisualComponentsOfCollection.cs
with GNU General Public License v3.0
from Adam-Wilkinson

public void CopyTo(IVisualNodeComponent[] array, int arrayIndex)
        {
            IEnumerator<IVisualNodeComponent> enumer = GetEnumerator();
            int i = 0;
            while (enumer.MoveNext())
            {
                array[i + arrayIndex] = enumer.Current;
                i++;
            }
        }

19 Source : AdColonyUtils.cs
with Apache License 2.0
from AdColony

bool SerializeObject(Hashtable anObject, StringBuilder builder)
        {
            builder.Append("{");

            IDictionaryEnumerator e = anObject.GetEnumerator();
            bool first = true;
            while (e.MoveNext())
            {
                string key = e.Key.ToString();
                object value = e.Value;

                if (!first)
                {
                    builder.Append(", ");
                }

                SerializeString(key, builder);
                builder.Append(":");
                if (!SerializeValue(value, builder))
                {
                    return false;
                }

                first = false;
            }

            builder.Append("}");
            return true;
        }

19 Source : StreamExtent.cs
with MIT License
from ADeltaX

public static IEnumerable<StreamExtent> Union(params IEnumerable<StreamExtent>[] streams)
        {
            long extentStart = long.MaxValue;
            long extentEnd = 0;

            // Initialize enumerations and find first stored byte position
            IEnumerator<StreamExtent>[] enums = new IEnumerator<StreamExtent>[streams.Length];
            bool[] streamsValid = new bool[streams.Length];
            int validStreamsRemaining = 0;
            for (int i = 0; i < streams.Length; ++i)
            {
                enums[i] = streams[i].GetEnumerator();
                streamsValid[i] = enums[i].MoveNext();
                if (streamsValid[i])
                {
                    ++validStreamsRemaining;
                    if (enums[i].Current.Start < extentStart)
                    {
                        extentStart = enums[i].Current.Start;
                        extentEnd = enums[i].Current.Start + enums[i].Current.Length;
                    }
                }
            }

            while (validStreamsRemaining > 0)
            {
                // Find the end of this extent
                bool foundIntersection;
                do
                {
                    foundIntersection = false;
                    validStreamsRemaining = 0;
                    for (int i = 0; i < streams.Length; ++i)
                    {
                        while (streamsValid[i] && enums[i].Current.Start + enums[i].Current.Length <= extentEnd)
                        {
                            streamsValid[i] = enums[i].MoveNext();
                        }

                        if (streamsValid[i])
                        {
                            ++validStreamsRemaining;
                        }

                        if (streamsValid[i] && enums[i].Current.Start <= extentEnd)
                        {
                            extentEnd = enums[i].Current.Start + enums[i].Current.Length;
                            foundIntersection = true;
                            streamsValid[i] = enums[i].MoveNext();
                        }
                    }
                } while (foundIntersection && validStreamsRemaining > 0);

                // Return the discovered extent
                yield return new StreamExtent(extentStart, extentEnd - extentStart);

                // Find the next extent start point
                extentStart = long.MaxValue;
                validStreamsRemaining = 0;
                for (int i = 0; i < streams.Length; ++i)
                {
                    if (streamsValid[i])
                    {
                        ++validStreamsRemaining;
                        if (enums[i].Current.Start < extentStart)
                        {
                            extentStart = enums[i].Current.Start;
                            extentEnd = enums[i].Current.Start + enums[i].Current.Length;
                        }
                    }
                }
            }
        }

19 Source : StreamExtent.cs
with MIT License
from ADeltaX

public static IEnumerable<StreamExtent> Intersect(params IEnumerable<StreamExtent>[] streams)
        {
            long extentStart = long.MinValue;
            long extentEnd = long.MaxValue;

            IEnumerator<StreamExtent>[] enums = new IEnumerator<StreamExtent>[streams.Length];
            for (int i = 0; i < streams.Length; ++i)
            {
                enums[i] = streams[i].GetEnumerator();
                if (!enums[i].MoveNext())
                {
                    // Gone past end of one stream (in practice was empty), so no intersections
                    yield break;
                }
            }

            int overlapsFound = 0;
            while (true)
            {
                // We keep cycling round the streams, until we get streams.Length continuous overlaps
                for (int i = 0; i < streams.Length; ++i)
                {
                    // Move stream on past all extents that are earlier than our candidate start point
                    while (enums[i].Current.Length == 0
                           || enums[i].Current.Start + enums[i].Current.Length <= extentStart)
                    {
                        if (!enums[i].MoveNext())
                        {
                            // Gone past end of this stream, no more intersections possible
                            yield break;
                        }
                    }

                    // If this stream has an extent that spans over the candidate start point
                    if (enums[i].Current.Start <= extentStart)
                    {
                        extentEnd = Math.Min(extentEnd, enums[i].Current.Start + enums[i].Current.Length);
                        overlapsFound++;
                    }
                    else
                    {
                        extentStart = enums[i].Current.Start;
                        extentEnd = extentStart + enums[i].Current.Length;
                        overlapsFound = 1;
                    }

                    // We've just done a complete loop of all streams, they overlapped this start position
                    // and we've cut the extent's end down to the shortest run.
                    if (overlapsFound == streams.Length)
                    {
                        yield return new StreamExtent(extentStart, extentEnd - extentStart);
                        extentStart = extentEnd;
                        extentEnd = long.MaxValue;
                        overlapsFound = 0;
                    }
                }
            }
        }

19 Source : MethodHelpers.cs
with MIT License
from ADeltaX

public static IEnumerable<T> SkipLast<T>(this IEnumerable<T> source, int count)
        {
            var e = source.GetEnumerator();
            var cache = new Queue<T>(count + 1);

            using (e = source.GetEnumerator())
            {
                bool hasRemainingItems;
                do
                {
                    if (hasRemainingItems = e.MoveNext())
                    {
                        cache.Enqueue(e.Current);
                        if (cache.Count > count)
                            yield return cache.Dequeue();
                    }
                } while (hasRemainingItems);
            }
        }

19 Source : ObjectShredder.cs
with MIT License
from Adoxio

public DataTable Shred(IEnumerable<T> source, DataTable table, LoadOption? options)
		{
			// Load the table from the scalar sequence if T is a primitive type.
			if (typeof(T).IsPrimitive)
			{
				return ShredPrimitive(source, table, options);
			}

			// Create a new table if the input table is null.
			if (table == null)
			{
				table = new DataTable(typeof(T).Name);
			}

			// Initialize the ordinal map and extend the table schema based on type T.
			table = ExtendTable(table, typeof(T));

			// Enumerate the source sequence and load the object values into rows.
			table.BeginLoadData();
			using (IEnumerator<T> e = source.GetEnumerator())
			{
				while (e.MoveNext())
				{
					if (options != null)
					{
						table.LoadDataRow(ShredObject(table, e.Current), (LoadOption)options);
					}
					else
					{
						table.LoadDataRow(ShredObject(table, e.Current), true);
					}
				}
			}
			table.EndLoadData();

			// Return the table.
			return table;
		}

19 Source : ObjectShredder.cs
with MIT License
from Adoxio

public DataTable ShredPrimitive(IEnumerable<T> source, DataTable table, LoadOption? options)
		{
			// Create a new table if the input table is null.
			if (table == null)
			{
				table = new DataTable(typeof(T).Name);
			}

			if (!table.Columns.Contains("Value"))
			{
				table.Columns.Add("Value", typeof(T));
			}

			// Enumerate the source sequence and load the scalar values into rows.
			table.BeginLoadData();
			using (IEnumerator<T> e = source.GetEnumerator())
			{
				var values = new object[table.Columns.Count];
				while (e.MoveNext())
				{
					values[table.Columns["Value"].Ordinal] = e.Current;

					if (options != null)
					{
						table.LoadDataRow(values, (LoadOption)options);
					}
					else
					{
						table.LoadDataRow(values, true);
					}
				}
			}
			table.EndLoadData();

			// Return the table.
			return table;
		}

19 Source : Expression.cs
with MIT License
from Adoxio

public Expression GetOperand()
		{
			var enumerator = Operands.GetEnumerator();
			enumerator.MoveNext();
			return enumerator.Current;
		}

19 Source : CrmEntityDataBoundControl.cs
with MIT License
from Adoxio

protected object GetDataObject(IEnumerable data)
		{
			if (data == null)
			{
				return null;
			}
			
			var enumerator = data.GetEnumerator();

			if (!enumerator.MoveNext())
			{
				return null;
			}

			if (enumerator.Current is CrmSiteMapNode)
			{
				return (enumerator.Current as CrmSiteMapNode).Enreplacedy;
			}

			return enumerator.Current;
		}

19 Source : ProgressIndicator.cs
with MIT License
from Adoxio

protected int RenderTypereplacedle(IEnumerable dataSource)
		{
			var count = 0;
			var clreplacedName = "progress list-group";
			var controlContainer = new HtmlGenericControl("ol");
			var e = dataSource.GetEnumerator();

			if (string.IsNullOrWhiteSpace(Position))
			{
				controlContainer.Attributes["clreplaced"] = clreplacedName;
			}
			else
			{
				switch (Position.ToLowerInvariant())
				{
					case "top":
						clreplacedName += " top";
						break;
					case "bottom":
						clreplacedName += " bottom";
						break;
					case "left":
						clreplacedName += " left";
						CssClreplaced += " col-sm-3 col-md-2";
						break;
					case "right":
						clreplacedName += " right";
						CssClreplaced += " col-sm-3 col-sm-push-9 col-md-2 col-md-push-10";
						break;
				}

				controlContainer.Attributes["clreplaced"] = clreplacedName;
			}

			while (e.MoveNext())
			{
				AddStep(e.Current, controlContainer);
				count++;
			}

			Controls.Add(controlContainer);

			return count;
		}

19 Source : ProgressIndicator.cs
with MIT License
from Adoxio

protected int RenderTypeNumeric(IEnumerable dataSource)
		{
			var count = 0;
			var progressIndex = 0;
			var clreplacedName = "progress-numeric";
			
			var e = dataSource.GetEnumerator();

			if (string.IsNullOrWhiteSpace(Position))
			{
				CssClreplaced = string.Join(" ", CssClreplaced, clreplacedName);
			}
			else
			{
				switch (Position.ToLowerInvariant())
				{
					case "top":
						clreplacedName += " top";
						break;
					case "bottom":
						clreplacedName += " bottom";
						break;
					case "left":
						clreplacedName += " left";
						CssClreplaced += " col-sm-3 col-md-2";
						break;
					case "right":
						clreplacedName += " right";
						CssClreplaced += " col-sm-3 col-sm-push-9 col-md-2 col-md-push-10";
						break;
				}

				CssClreplaced = string.Join(" ", CssClreplaced, clreplacedName);
			}

			while (e.MoveNext())
			{
				if (e.Current == null)
				{
					continue;
				}

				var indexValue = DataBinder.GetPropertyValue(e.Current, IndexDataPropertyName);
				var activeValue = DataBinder.GetPropertyValue(e.Current, ActiveDataPropertyName);
				var index = Convert.ToInt32(indexValue);
				var active = Convert.ToBoolean(activeValue);

				if (active)
				{
					progressIndex = ZeroBasedIndex ? index + 1 : index;
				}

				count++;
			}

			var literal = new LiteralControl { Text = string.Format("{0} <span clreplaced='number'>{1}</span> of <span clreplaced='number total'>{2}</span>", NumericPrefix, progressIndex, count) };
			
			Controls.Add(literal);

			return count;
		}

19 Source : ProgressIndicator.cs
with MIT License
from Adoxio

protected int RenderTypeProgressBar(IEnumerable dataSource)
		{
			var count = 0;
			var progressIndex = 0;
			var clreplacedName = "progress";
			var controlContainer = new HtmlGenericControl("div");
			
			var e = dataSource.GetEnumerator();

			if (string.IsNullOrWhiteSpace(Position))
			{
				CssClreplaced = string.Join(" ", CssClreplaced, clreplacedName);
			}
			else
			{
				switch (Position.ToLowerInvariant())
				{
					case "top":
						clreplacedName += " top";
						break;
					case "bottom":
						clreplacedName += " bottom";
						break;
					case "left":
						clreplacedName += " left";
						CssClreplaced += " col-sm-3 col-md-2";
						break;
					case "right":
						clreplacedName += " right";
						CssClreplaced += " col-sm-3 col-sm-push-9 col-md-2 col-md-push-10";
						break;
				}

				CssClreplaced = string.Join(" ", CssClreplaced, clreplacedName);
			}

			while (e.MoveNext())
			{
				if (e.Current == null)
				{
					continue;
				}

				var indexValue = DataBinder.GetPropertyValue(e.Current, IndexDataPropertyName);
				var activeValue = DataBinder.GetPropertyValue(e.Current, ActiveDataPropertyName);
				var index = Convert.ToInt32(indexValue);
				var active = Convert.ToBoolean(activeValue);
				
				if (active)
				{
					if (ZeroBasedIndex)
					{
						index++;
					}

					progressIndex = index > 0 ? index - 1 : 0;
				}
				
				count++;
			}

			controlContainer.Attributes["clreplaced"] = "bar progress-bar";

			double percent = 0;

			if (count > 0)
			{
				if (!CountLastStepInProgress)
				{
					percent = (double)(progressIndex * 100) / (count - 1);
				}
				else
				{
					percent = (double)(progressIndex * 100) / count;
				}
			}

			var progress = Math.Floor(percent);

			controlContainer.Attributes["style"] = string.Format("width: {0}%;", progress);
			controlContainer.Attributes["role"] = "progressbar";
			controlContainer.Attributes["aria-valuemin"] = "0";
			controlContainer.Attributes["aria-valuemax"] = "100";
			controlContainer.Attributes["aria-valuenow"] = progress.ToString(CultureInfo.InvariantCulture);

			if (progress.CompareTo(0) == 0)
			{
				controlContainer.Attributes["clreplaced"] = controlContainer.Attributes["clreplaced"] + " zero";
			}

			controlContainer.InnerHtml = string.Format("{0}%", progress);

			Controls.Add(controlContainer);

			return count;
		}

19 Source : Coroutines.cs
with MIT License
from adrenak

bool MoveNext(IEnumerator routine, int index) {
            if (routine.Current is IEnumerator) {
                if (MoveNext((IEnumerator)routine.Current, index))
                    return true;

                delays[index] = 0f;
            }

            bool result = routine.MoveNext();

            if (routine.Current is float)
                delays[index] = (float)routine.Current;

            return result;
        }

19 Source : Parallel.cs
with MIT License
from adrenak

private void RunWorkerThread(object threadIndex) {
                WorkerThread workerThread = workerThreads[(int)threadIndex];

                while (true) {
                    // Wait for a task.
                    workerThread.TaskWaiting.WaitOne();

                    // Exit if task is empty.
                    if (LoopFunction == null) {
                        return;
                    }

                    bool didMoveNext;
                    T localItem = default(T);
                    lock (this.enumerator) {
                        didMoveNext = enumerator.MoveNext();
                        if (didMoveNext) {
                            localItem = enumerator.Current;
                        }
                    }

                    while (didMoveNext == true) {
                        ////Console.WriteLine("Thread " + threadIndex + " of " + workerThreads.Count + " running task " + localJobIndex);
                        LoopFunction(localItem);
                        lock (this.enumerator) {
                            didMoveNext = enumerator.MoveNext();
                            if (didMoveNext) {
                                localItem = enumerator.Current;
                            }
                        }
                    }

                    // Signal that thread is idle.
                    workerThread.ThreadIdle.Set();
                }
            }

19 Source : Parallel.cs
with MIT License
from adrenak

private void RunWorkerThread(object threadIndex) {
				WorkerThread workerThread = workerThreads[(int)threadIndex];

				while(true) {
					// Wait for a task.
					workerThread.TaskWaiting.WaitOne();

					// Exit if task is empty.
					if(LoopFunction == null) {
						return;
					}

					bool didMoveNext;
					T localItem = default(T);
					lock (this.enumerator) {
						didMoveNext = enumerator.MoveNext();
						if(didMoveNext) {
							localItem = enumerator.Current;
						}
					}

					while(didMoveNext == true) {
						////Console.WriteLine("Thread " + threadIndex + " of " + workerThreads.Count + " running task " + localJobIndex);
						LoopFunction(localItem);
						lock (this.enumerator) {
							didMoveNext = enumerator.MoveNext();
							if(didMoveNext) {
								localItem = enumerator.Current;
							}
						}
					}

					// Signal that thread is idle.
					workerThread.ThreadIdle.Set();
				}
			}

See More Examples