public static void ContainsInOrder <T>(IEnumerable <T> list, params Predicate <T>[] conditions) { IEnumerator <Predicate <T> > condition = ((IEnumerable <Predicate <T> >)conditions).GetEnumerator(); int numMet = 0; if (!condition.MoveNext()) { return; } foreach (var item in list) { if (condition.Current(item)) { ++numMet; // have all conditions been met? if (!condition.MoveNext()) { return; } } } Assert.AreEqual(conditions.Length, numMet, "Items in the list did not match the conditions"); }
private void RunNextAction() { if (_actions.MoveNext()) { _actions.Current(RunNextAction); } }
private static async Task RunInSeries(IEnumerator <Func <Task> > enumerator) { if (enumerator.MoveNext()) { await enumerator.Current(); await RunInSeries(enumerator); } }
public void Move() { IfMustBeMoved(() => { _directionEnumerator.MoveNext(); var result = _directionEnumerator.Current(CurrentPosition); Move(result.MatchingObject); }); }
void Update() { IEnumerator <System.Action> ite = repeat_scheduler_list.GetEnumerator(); while (ite.MoveNext()) { ite.Current(); } }
public void DeliverMessageToConsumers(object message) { try { NotifyReceiveCompleted(); _receiveTime.Stop(); _consumeTime.Start(); if (_log.IsDebugEnabled) { _log.DebugFormat("Dispatching message on {0} from thread {1}", _bus.Endpoint.Uri, Thread.CurrentThread.ManagedThreadId); } bool atLeastOneConsumerFailed = false; Exception lastException = null; do { try { _consumers.Current(message); _consumeCount++; } catch (Exception ex) { _log.Error(string.Format("'{0}' threw an exception consuming message '{1}'", _consumers.Current.GetType().FullName, message.GetType().FullName), ex); atLeastOneConsumerFailed = true; lastException = ex; CreateAndPublishFault(message, ex); } } while (_consumers.MoveNext()); if (atLeastOneConsumerFailed) { throw new MessageException(message.GetType(), "At least one consumer threw an exception", lastException); } } finally { _consumeTime.Stop(); _consumers.Dispose(); _consumers = null; ReportConsumerTime(message.GetType(), _receiveTime.Elapsed, _consumeTime.Elapsed); ReportConsumerCount(message.GetType(), _consumeCount); } }
public void InsertData(IEffectNode effectNode) { bool cancel = false; using (IEnumerator <DataListener> enumerator = _listeners.GetEnumerator()) { while (!cancel && enumerator.MoveNext()) { cancel = enumerator.Current(effectNode); } } }
public void DoWork(string command) { if (thread != null) { thread.Current(command); if (!thread.MoveNext()) { init(); } } }
private void ExecuteNext() { _actions.Current(); if (_actions.MoveNext()) { _asyncTask.Execute(_delayer, ExecuteNext); } else { _completedCallback(); } }
internal void InvokeOnSerialized(object o, StreamingContext context) { if (this._onSerializedCallbacks != null) { using (IEnumerator <SerializationCallback> enumerator = this._onSerializedCallbacks.GetEnumerator()) { while (enumerator.MoveNext()) { enumerator.Current(o, context); } } } }
public bool MoveNext() { Current = PermuteValueSet(); bool prevResult = _hasMoreResults; _hasMoreResults = _generatorIterator !.MoveNext(); if (_hasMoreResults) { _generatorIterator.Current(); } return(prevResult); }
// Utility that grab all check within the scope or in sub scope included and check if everything is correct bool IsAllEntryCorrectInScope(InclusiveScope scope) { IEnumerable <Entry.Checker> checks = entries.Where(e => scope.Contains(e.scope)).Select(e => e.check); if (checks.Count() == 0) { return(true); } IEnumerator <Entry.Checker> enumerator = checks.GetEnumerator(); enumerator.MoveNext(); bool result = enumerator.Current(); if (enumerator.MoveNext()) { for (; result && enumerator.MoveNext();) { result &= enumerator.Current(); } } return(result); }
public void Update(GameTime gameTime) { if (actionTask != null) { if (actionTask.MoveNext()) { actionTask.Current(gameTime); } else { actionCompleted.OnNext(Unit.Default); actionTask = null; } } }
public static void RunSequential(Action onComplete, Action <Exception> errorHandler, IEnumerator <Func <Task> > actions) { if (!actions.MoveNext()) { onComplete(); return; } var task = actions.Current(); task.ContinueWith(t => errorHandler(t.Exception), TaskContinuationOptions.OnlyOnFaulted); task.ContinueWith(t => RunSequential(onComplete, errorHandler, actions), TaskContinuationOptions.OnlyOnRanToCompletion); }
public void WriteLine(object value) { try { _callbacks.Current(value.ToString()); if (!_callbacks.MoveNext()) { _completion.SetResult(null); } } catch (Exception e) { _completion.SetException(e); } }
public void Update() { if (dispatch != null && dispatch.MoveNext()) { do { dispatch.Current(); }while(dispatch.MoveNext()); return; } if (events.Count > 0) { dispatch = events.Dequeue().Handlers().GetEnumerator(); } }
public bool MoveNext() { Current = PermuteValueSet(); // check if more permutation left to enumerate var prevResult = _hasMoreResults; _hasMoreResults = _generatorIterator.MoveNext(); if (_hasMoreResults) { _generatorIterator.Current(); // produce the next permutation ordering } // we return prevResult rather than m_HasMoreResults because there is always // at least one permtuation: the original set. Also, this provides a simple way // to deal with the disparity between sets that have only one loop level (size 0-2) // and those that have two or more (size > 2). return(prevResult); }
public IContainer Build(params Assembly[] assemblies) { Type baseType = typeof(IDependency); using (IEnumerator <Action <ContainerBuilder> > enumerator = this.GetBuildingActions().GetEnumerator()) { while (enumerator.MoveNext()) { enumerator.Current(builder); } } builder.RegisterAssemblyTypes(assemblies) .Where(type => baseType.IsAssignableFrom(type) && !type.IsAbstract) .AsImplementedInterfaces() .InstancePerLifetimeScope(); //InstancePerLifetimeScope 保证对象生命周期基于请求 IContainer container = builder.Build(0); CoreBuilderWork.LifetimeScope = container; return(container); }
public void ExecuteCaptureActions(RTHandleSystem.RTHandle input, CommandBuffer cmd) { if (m_RecorderCaptureActions == null || !m_RecorderCaptureActions.MoveNext()) { return; } // We need to blit to an intermediate texture because input resolution can be bigger than the camera resolution // Since recorder does not know about this, we need to send a texture of the right size. cmd.GetTemporaryRT(m_RecorderTempRT, actualWidth, actualHeight, 0, FilterMode.Point, input.rt.graphicsFormat); var blitMaterial = HDUtils.GetBlitMaterial(TextureDimension.Tex2D); m_RecorderPropertyBlock.SetTexture(HDShaderIDs._BlitTexture, input); m_RecorderPropertyBlock.SetVector(HDShaderIDs._BlitScaleBias, viewportScale); m_RecorderPropertyBlock.SetFloat(HDShaderIDs._BlitMipLevel, 0); cmd.SetRenderTarget(m_RecorderTempRT); cmd.DrawProcedural(Matrix4x4.identity, blitMaterial, 0, MeshTopology.Triangles, 3, 1, m_RecorderPropertyBlock); for (m_RecorderCaptureActions.Reset(); m_RecorderCaptureActions.MoveNext();) { m_RecorderCaptureActions.Current(m_RecorderTempRT, cmd); } }
public IContainer Build() { var configuration = GlobalConfiguration.Configuration; Type baseType = typeof(IDependency); // 获取所有相关类库的程序集 //Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); Assembly[] assemblies = BuildManager.GetReferencedAssemblies().Cast <Assembly>().ToArray(); using (IEnumerator <Action <ContainerBuilder> > enumerator = this.GetBuildingActions().GetEnumerator()) { while (enumerator.MoveNext()) { enumerator.Current(builder); } } //注册mvc conrollers builder.RegisterControllers(assemblies); //注册api conrollers builder.RegisterApiControllers(assemblies); builder.RegisterAssemblyTypes(assemblies) .Where(type => baseType.IsAssignableFrom(type) && !type.IsAbstract) .AsImplementedInterfaces() .InstancePerLifetimeScope(); //InstancePerLifetimeScope 保证对象生命周期基于请求 IContainer container = builder.Build(0); //注册api容器需要使用HttpConfiguration对象 configuration.DependencyResolver = new AutofacWebApiDependencyResolver(container); //注册mvc容器 DependencyResolver.SetResolver(new AutofacDependencyResolver(container)); CoreBuilderWork.LifetimeScope = container; return(container); }
static void Load(object obj, BinaryReader reader, Type type, IEnumerator <Func <object, UInt32> > enumArrayLength, params object[] parameters) { Type baseType = type.BaseType; if (baseType != null) { Load(obj, reader, baseType, enumArrayLength, parameters); } FieldInfo[] fis = type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public); foreach (FieldInfo fi in fis) { Type fieldType = fi.FieldType; if (fieldType.IsArray) { if (enumArrayLength == null || !enumArrayLength.MoveNext()) { throw new ArgumentException("ClassLoader.Load : invalid enumArrayLength."); } UInt32 count = enumArrayLength.Current(obj); Type elementType = fieldType.GetElementType(); if (elementType != null) { TTFClassLoader creator = new TTFClassLoader(elementType, parameters); Array array = creator.CreateArray(reader, count); fi.SetValue(obj, array); } } else { TTFClassLoader creator = new TTFClassLoader(fieldType, parameters); object value = creator.Create(reader); fi.SetValue(obj, value); } } }
private T GetNext(CallInfo info) { _valuesToReturn.MoveNext(); return(_valuesToReturn.Current(info)); }
public static decimal ApplyCalculations(IEnumerator <Func <decimal, decimal> > enumerator, decimal currentTotal) => enumerator.MoveNext() ? ApplyCalculations(enumerator, enumerator.Current(currentTotal)) : currentTotal;
public TU Transform(T occurence) { _returnValues.MoveNext(); ValuesSupplied.Add(occurence); return(_returnValues.Current(occurence)); }
private static bool NextHelper(Type t, object value, StringBuilder trace, ref object result, IEnumerator <Handle> nexts) { return(nexts.MoveNext() && nexts.Current(t, value, trace, ref result, nexts)); }
public void Current_Null() { var arr = new IEnumerator[1]; Assert.IsTrue(arr.Current().Empty()); }
public static T AggregateFunc <T>(IEnumerator <Func <T, T> > e, T agg = default(T)) => e.MoveNext() ? AggregateFunc(e, e.Current(agg)) : agg;
/// <summary> /// Creates a bitmap of the graph. /// </summary> /// <param name="Settings">Graph settings.</param> /// <param name="States">State object(s) that contain graph-specific information about its inner states. /// These can be used in calls back to the graph object to make actions on the generated graph.</param> /// <returns>Bitmap</returns> public override SKImage CreateBitmap(GraphSettings Settings, out object[] States) { using (SKSurface Surface = SKSurface.Create(Settings.Width, Settings.Height, SKImageInfo.PlatformColorType, SKAlphaType.Premul)) { SKCanvas Canvas = Surface.Canvas; States = new object[0]; Canvas.Clear(Settings.BackgroundColor); int x1, y1, x2, y2, x3, y3, w, h; x1 = Settings.MarginLeft; x2 = Settings.Width - Settings.MarginRight; y1 = Settings.MarginTop; y2 = Settings.Height - Settings.MarginBottom; IVector YLabels = GetLabels(ref this.minY, ref this.maxY, this.y, Settings.ApproxNrLabelsY, out LabelType YLabelType); SKPaint Font = new SKPaint() { FilterQuality = SKFilterQuality.High, HintingLevel = SKPaintHinting.Full, SubpixelText = true, IsAntialias = true, Style = SKPaintStyle.Fill, Color = Settings.AxisColor, Typeface = SKTypeface.FromFamilyName(Settings.FontName, SKTypefaceStyle.Normal), TextSize = (float)Settings.LabelFontSize }; float Size; double MaxSize = 0; if (this.showYAxis) { foreach (IElement Label in YLabels.ChildElements) { Size = Font.MeasureText(LabelString(Label, YLabelType)); if (Size > MaxSize) { MaxSize = Size; } } } x3 = (int)Math.Ceiling(x1 + MaxSize) + Settings.MarginLabel; IVector XLabels = GetLabels(ref this.minX, ref this.maxX, this.x, Settings.ApproxNrLabelsX, out LabelType XLabelType); MaxSize = 0; if (this.showXAxis) { foreach (IElement Label in XLabels.ChildElements) { Size = Font.MeasureText(LabelString(Label, XLabelType)); if (Size > MaxSize) { MaxSize = Size; } } } y3 = (int)Math.Floor(y2 - MaxSize) - Settings.MarginLabel; w = x2 - x3; h = y3 - y1; SKPaint AxisBrush = new SKPaint() { FilterQuality = SKFilterQuality.High, IsAntialias = true, Style = SKPaintStyle.Fill, Color = Settings.AxisColor }; SKPaint GridBrush = new SKPaint() { FilterQuality = SKFilterQuality.High, IsAntialias = true, Style = SKPaintStyle.Fill, Color = Settings.GridColor }; SKPaint AxisPen = new SKPaint() { FilterQuality = SKFilterQuality.High, IsAntialias = true, Style = SKPaintStyle.Stroke, Color = Settings.AxisColor, StrokeWidth = Settings.AxisWidth }; SKPaint GridPen = new SKPaint() { FilterQuality = SKFilterQuality.High, IsAntialias = true, Style = SKPaintStyle.Stroke, Color = Settings.GridColor, StrokeWidth = Settings.GridWidth }; double OrigoX; double OrigoY; if (this.minX.AssociatedSet is IAbelianGroup AgX) { OrigoX = Scale(new ObjectVector(AgX.AdditiveIdentity), this.minX, this.maxX, x3, w)[0]; } else { OrigoX = 0; } if (this.minY.AssociatedSet is IAbelianGroup AgY) { OrigoY = Scale(new ObjectVector(AgY.AdditiveIdentity), this.minY, this.maxY, y3, -h)[0]; } else { OrigoY = 0; } DrawingArea DrawingArea = new DrawingArea(this.minX, this.maxX, this.minY, this.maxY, x3, y3, w, -h, (float)OrigoX, (float)OrigoY); double[] LabelYY = DrawingArea.ScaleY(YLabels); int i = 0; float f; string s; foreach (IElement Label in YLabels.ChildElements) { Size = Font.MeasureText(s = LabelString(Label, YLabelType)); f = (float)LabelYY[i++]; if (this.showGrid) { if (Label is DoubleNumber && ((DoubleNumber)Label).Value == 0) { Canvas.DrawLine(x3, f, x2, f, AxisPen); } else { Canvas.DrawLine(x3, f, x2, f, GridPen); } } if (this.showYAxis) { f += (float)Settings.LabelFontSize * 0.5f; Canvas.DrawText(s, x3 - Size - Settings.MarginLabel, f, Font); } } double[] LabelXX = DrawingArea.ScaleX(XLabels); i = 0; foreach (IElement Label in XLabels.ChildElements) { Size = Font.MeasureText(s = LabelString(Label, XLabelType)); f = (float)LabelXX[i++]; if (this.showGrid) { if (Label is DoubleNumber && ((DoubleNumber)Label).Value == 0) { Canvas.DrawLine(f, y1, f, y3, AxisPen); } else { Canvas.DrawLine(f, y1, f, y3, GridPen); } } if (this.showXAxis) { f -= Size * 0.5f; if (f < x3) { f = x3; } else if (f + Size > x3 + w) { f = x3 + w - Size; } Canvas.DrawText(s, f, y3 + Settings.MarginLabel + (float)Settings.LabelFontSize, Font); } } IEnumerator <IVector> ex = this.x.GetEnumerator(); IEnumerator <IVector> ey = this.y.GetEnumerator(); IEnumerator <object[]> eParameters = this.parameters.GetEnumerator(); IEnumerator <DrawCallback> eCallbacks = this.callbacks.GetEnumerator(); SKPoint[] Points; SKPoint[] PrevPoints = null; object[] PrevParameters = null; DrawCallback PrevCallback = null; while (ex.MoveNext() && ey.MoveNext() && eParameters.MoveNext() && eCallbacks.MoveNext()) { Points = DrawingArea.Scale(ex.Current, ey.Current); if (PrevCallback != null && eCallbacks.Current.Target.GetType() == PrevCallback.Target.GetType()) { eCallbacks.Current(Canvas, Points, eParameters.Current, PrevPoints, PrevParameters, DrawingArea); } else { eCallbacks.Current(Canvas, Points, eParameters.Current, null, null, DrawingArea); } PrevPoints = Points; PrevParameters = eParameters.Current; PrevCallback = eCallbacks.Current; } SKImage Result = Surface.Snapshot(); Font.Dispose(); AxisBrush.Dispose(); GridBrush.Dispose(); GridPen.Dispose(); AxisPen.Dispose(); States = new object[] { DrawingArea }; return(Result); } }
public T Get() { _returnValues.MoveNext(); _valuesSupplied.Add(_returnValues.Current()); return(_returnValues.Current()); }