public void AddPolygon(int count, IEnumerable<int> indices, int? tag) { PrevalidateGeometry(); //Error out on polygons not matching, for the sake of being consistent with AW and other RWX loaders. if(indices.Count() != count) { throw new InvalidOperationException("Polygon vertex count mismatch."); } _currentMeshGeometry.Faces.Add(new Face { Indices = indices.ToList(), MaterialId = _model.AddMaterial(_currentMaterial), Tag = tag, Triangles = TessellatePolygon(indices).ToList() }); if(_currentMaterial.MaterialMode == MaterialMode.Double) { _currentMeshGeometry.Faces.Add(new Face { Indices = indices.Reverse().ToList(), MaterialId = _model.AddMaterial(_currentMaterial), Tag = tag, Triangles = TessellatePolygon(indices.Reverse()).ToList() }); } }
public static List<MinimalJobStats> GatherCurrentJobs(IEnumerable<JobItem> work, string filter) { return work .Reverse() .Where(x => { if (String.IsNullOrWhiteSpace(filter) || filter == "all") { return true; } if (filter == "running" && x.Status == JobStatus.Running) { return true; } if (filter == "failing" && GatherJobHealth(x) == JobHealth.Bad) { return true; } return false; }) .Select(x => new MinimalJobStats { JobKey = x.JobKey, Description = x.Description, CurrentStatus = (InlineScheduler.JobStatus)x.Status, Health = GatherJobHealth(x), Report = GatherJobReport(x) }).ToList(); }
private void LoadButtons(IEnumerable<CustomDialogButtonInfo> buttons) { const int buttonMargin = 20; var leftPosition = pnButtons.Width; var buttonHeight = pnButtons.Height - buttonMargin; var topPosition = (pnButtons.Height - buttonHeight) / 2; foreach (var buttonInfo in buttons.Reverse().ToList()) { var button = new ButtonX(); button.ColorTable = eButtonColor.OrangeWithBackground; button.Text = buttonInfo.Title; button.DialogResult = buttonInfo.DialogResult; button.TextColor = Color.Black; button.Height = buttonHeight; button.Width = buttonInfo.Width; button.Style = eDotNetBarStyle.StyleManagerControlled; button.Top = topPosition; button.Anchor = AnchorStyles.Top | AnchorStyles.Right; leftPosition -= button.Width; button.Left = leftPosition; leftPosition -= buttonMargin; pnButtons.Controls.Add(button); } }
public static SchedulerStats GatherOveralStatistics(IEnumerable<WorkItem> _work) { var stats = new SchedulerStats(); stats.CurrentJobs = _work .Reverse() .Select(x => new SchedulerJobStats { WorkKey = x.WorkKey, Description = x.Description, CurrentStatus = (SchedulerJobStatus)x.Status, LastRunStarted = x.LastStart, LastRunCompleted = x.LastComplete, PreviousRuns = x.PreviousRuns.Select(xx => new SchedulerJobRunStats { Started = xx.Started, Completed = xx.Completed, Result = (SchedulerJobRunResult)xx.Result, ResultMessage = xx.ResultMessage }).ToList() }).ToList(); stats.PendingJobs = stats.CurrentJobs.Count(x => x.CurrentStatus == SchedulerJobStatus.Pending); stats.RunningJobs = stats.CurrentJobs.Count(x => x.CurrentStatus == SchedulerJobStatus.Running); stats.ScheduledJobs = stats.CurrentJobs.Count(x => x.CurrentStatus == SchedulerJobStatus.Scheduled); return stats; }
public void VisitNodes( IEnumerable<DependencyObject> nodes ) { if( nodes == null ) return; m_collection.AddRange( nodes.Reverse() ); }
public ForecastEntry Forecast(IEnumerable<DataEntry> dataEntries, int period, dynamic strategyParameters) { if (period - 1 < 0) return null; int numberOfPeriods = strategyParameters.PeriodCount; if (numberOfPeriods > dataEntries.Count()) throw new ArgumentException("The number of periods can not be greater than the number of entries."); double value; if (dataEntries.Count() == 1 || period == 1) value = dataEntries.ElementAt(0).Value; else if (period < numberOfPeriods) value = dataEntries.ElementAt(period - 1).Value; else if (dataEntries.Count() > 1 && period <= dataEntries.Count() + 1) value = dataEntries.Take(period - 1).Reverse().Take(numberOfPeriods).Reverse().Sum(entry => (entry.Value))/ numberOfPeriods; else value = dataEntries.Reverse().Take(numberOfPeriods).Reverse().Sum(entry => (entry.Value))/ numberOfPeriods; return new ForecastEntry { Period = period, DataEntry = period > dataEntries.Count() ? dataEntries.Last() : dataEntries.ElementAt(period - 1), ForecastValue = value, ConfidenceIntervalLow = value, ConfidenceIntervalHigh = value, IsHoldout = period > dataEntries.Count()*0.7 //holdout data is always 70 percent }; }
/// <summary> /// Convert a list of digits into a number. /// </summary> /// <param name="DigitsToConvertToANumber">Digits to convert to a number</param> /// <returns>The combined number</returns> private static int ArrayOfSingleDigitsToNumber(IEnumerable<int> DigitsToConvertToANumber) { //ie: //[0] = 3 //[1] = 5 //[2] = 7 // ==> 357 //tally var RunningTally = 0; //what we multiple with var MultiplyValue = 1; //loop through all of them and multiple everything foreach (var Digit in DigitsToConvertToANumber.Reverse()) { //multiply and add it RunningTally += Digit * MultiplyValue; //now multiple by 10 MultiplyValue *= 10; } //return the result return RunningTally; }
/// <summary> /// Creates an instance of an <see cref="HttpMessageHandler"/> using the <see cref="DelegatingHandler"/> instances /// provided by <paramref name="handlers"/>. The resulting pipeline can be used to manually create <see cref="HttpClient"/> /// or <see cref="HttpMessageInvoker"/> instances with customized message handlers. /// </summary> /// <param name="innerHandler">The inner handler represents the destination of the HTTP message channel.</param> /// <param name="handlers">An ordered list of <see cref="DelegatingHandler"/> instances to be invoked as part /// of sending an <see cref="HttpRequestMessage"/> and receiving an <see cref="HttpResponseMessage"/>. /// The handlers are invoked in a top-down fashion. That is, the first entry is invoked first for /// an outbound request message but last for an inbound response message.</param> /// <returns>The HTTP message channel.</returns> public static HttpMessageHandler CreatePipeline(HttpMessageHandler innerHandler, IEnumerable<DelegatingHandler> handlers) { if (innerHandler == null) { throw Error.ArgumentNull("innerHandler"); } if (handlers == null) { return innerHandler; } // Wire handlers up in reverse order starting with the inner handler HttpMessageHandler pipeline = innerHandler; IEnumerable<DelegatingHandler> reversedHandlers = handlers.Reverse(); foreach (DelegatingHandler handler in reversedHandlers) { if (handler == null) { throw Error.Argument("handlers", Properties.Resources.DelegatingHandlerArrayContainsNullItem, typeof(DelegatingHandler).Name); } if (handler.InnerHandler != null) { throw Error.Argument("handlers", Properties.Resources.DelegatingHandlerArrayHasNonNullInnerHandler, typeof(DelegatingHandler).Name, "InnerHandler", handler.GetType().Name); } handler.InnerHandler = pipeline; pipeline = handler; } return pipeline; }
/// <summary> /// Creates a set of new Sound Resources based on the specified AudioData, saves it and returns references to it. /// The incoming AudioData is automatically grouped to the least number of Sounds, according to naming and path conventions. /// </summary> /// <param name="baseRes"></param> /// <returns></returns> public static List<ContentRef<Sound>> CreateMultipleFromAudioData(IEnumerable<ContentRef<AudioData>> baseRes) { char[] trimEndChars = new []{'0','1','2','3','4','5','6','7','8','9','_','-','.','#','~'}; List<ContentRef<AudioData>> sourceData = baseRes.Reverse().ToList(); List<ContentRef<Sound>> result = new List<ContentRef<Sound>>(); // Split data into singular data and grouped data while (sourceData.Count > 0) { ContentRef<AudioData> data = sourceData[sourceData.Count - 1]; string mutualName = data.Name.TrimEnd(trimEndChars); string mutualDir = System.IO.Path.GetDirectoryName(data.Path); // Group similar AudioData List<ContentRef<AudioData>> localGroup = new List<ContentRef<AudioData>>(); for (int i = sourceData.Count - 1; i >= 0; i--) { if (System.IO.Path.GetDirectoryName(sourceData[i].Path) != mutualDir) continue; if (!sourceData[i].Name.StartsWith(mutualName)) continue; localGroup.Add(sourceData[i]); sourceData.RemoveAt(i); } result.Add(Sound.CreateFromAudioData(localGroup, localGroup.Count > 1 ? mutualName : null)); } return result; }
static void run(IEnumerable<String> filePaths) { var p = new Parser(); var modules = new Dictionary<String, IReadOnlyList<IClassItem>>(); foreach (var path in filePaths.Reverse()) { Contract.Assume(path != null); var txt = File.ReadAllText(path); var items = p.Parse(txt, ValidationList); modules.Add(Path.GetFileNameWithoutExtension(path), items.Cast<IClassItem>().ToList()); } var preludeTxt = File.ReadAllText(libPath + "prelude.ef"); var preludeTxtItems = p.Parse(preludeTxt, ValidationList); var rw = new Rewriter(); var prog = rw.MakeProgram(preludeTxtItems.Cast<Declr>().ToList(), modules); var n = new Namer(); n.Name(prog, ValidationList); var ti = new TypeInferer(); ti.VisitDeclr(prog.GlobalModule); var i = new Interpreter(); var res = i.Run(prog, ValidationList); Console.Write("Result: "); Console.WriteLine(res.Accept(DefaultPrinter)); }
/// <summary> /// Inserts a group of instructions after the target instruction /// </summary> public static void InsertAfter(this Mono.Cecil.Cil.ILProcessor processor, Instruction target, IEnumerable<Instruction> instructions) { foreach (var instruction in instructions.Reverse()) { processor.InsertAfter(target, instruction); } }
public void AddRange(Player player, IEnumerable<Card> cardCollection, DeckPosition deckPosition) { switch (deckPosition) { case DeckPosition.Top: _Cards.InsertRange(0, cardCollection.Reverse()); break; case DeckPosition.Bottom: _Cards.AddRange(cardCollection); break; } this.Sort(); if (cardCollection.Count() > 0) { if (_AsynchronousChanging) { if (_AsynchronousPileChangedEventArgs == null) _AsynchronousPileChangedEventArgs = new PileChangedEventArgs(player, PileChangedEventArgs.Operation.Added, cardCollection); else _AsynchronousPileChangedEventArgs.AddedCards.AddRange(cardCollection); } else if (PileChanged != null) { lock (PileChanged) { PileChangedEventArgs pcea = new PileChangedEventArgs(player, PileChangedEventArgs.Operation.Added, cardCollection); PileChanged(this, pcea); } } } }
/// <summary>Creates a new instance of the <see cref="T:System.Net.Http.HttpClient" /> which should be pipelined.</summary> /// <returns>A new instance of the <see cref="T:System.Net.Http.HttpClient" /> which should be pipelined.</returns> /// <param name="innerHandler">The inner handler which is responsible for processing the HTTP response messages.</param> /// <param name="handlers">The list of HTTP handler that delegates the processing of HTTP response messages to another handler.</param> public static HttpMessageHandler CreatePipeline(HttpMessageHandler innerHandler, IEnumerable<DelegatingHandler> handlers) { if (innerHandler == null) { throw Error.ArgumentNull("innerHandler"); } if (handlers == null) { return innerHandler; } HttpMessageHandler handler = innerHandler; foreach (DelegatingHandler handler2 in handlers.Reverse<DelegatingHandler>()) { if (handler2 == null) { // todo: reenable error throw throw Error.Argument("handlers", FSR.DelegatingHandlerArrayContainsNullItem, new object[] { typeof(DelegatingHandler).Name }); } if (handler2.InnerHandler != null) { // todo: reenable error throw throw Error.Argument("handlers", FSR.DelegatingHandlerArrayHasNonNullInnerHandler, new object[] { typeof(DelegatingHandler).Name, "InnerHandler", handler2.GetType().Name }); } handler2.InnerHandler = handler; handler = handler2; } return handler; }
internal string ExpandString(IEnumerable<object> expandedValues) { expandedValues = expandedValues.Reverse(); var exValEnumerator = expandedValues.GetEnumerator(); var resultStr = new StringBuilder(); string rest = Value; // we expand this string in reversed order so we don't need to adjust start indexes foreach (var item in NestedExpressions.Reverse()) { if (!exValEnumerator.MoveNext()) { break; } // first find the relative position of the expandable part inside our string string value = LanguagePrimitives.ConvertTo<string>(exValEnumerator.Current); var relStart = item.Extent.StartOffset - Extent.StartOffset - 1; var relEnd = item.Extent.EndOffset - Extent.StartOffset - 1; // the end are constant words between this expression and the last resolved expression // we need to resolve escape constants before adding it var resolvedEnd = StringExpressionHelper.ResolveEscapeCharacters(rest.Substring(relEnd), StringConstantType); // as we do it in reverse order: insert at the beginning, in reverse order resultStr.Insert(0, resolvedEnd).Insert(0, value); // finally strip the rest which needs to be expanded rest = rest.Substring(0, relStart); } // now insert the rest at the beginning (other constant string) resultStr.Insert(0, StringExpressionHelper.ResolveEscapeCharacters(rest, StringConstantType)); return resultStr.ToString(); }
/// <summary> /// Implementation using kill /// </summary> /// <param name="pids"></param> internal static void KillImpl (IEnumerable<int> pids) { using (Process quit = new Process ()) { quit.StartInfo.FileName = "kill"; quit.StartInfo.Arguments = "-QUIT "; foreach (int pid in pids.Reverse()) { quit.StartInfo.Arguments += pid.ToString () + " "; } quit.StartInfo.UseShellExecute = false; quit.Start (); if (!quit.WaitForExit (1000 * 15 /* 15 seconds */)) throw new ApplicationException (string.Format ("The 'kill -QUIT' process didn't exit in 15 seconds.")); } using (Process kill = new Process ()) { kill.StartInfo.FileName = "kill"; kill.StartInfo.Arguments = "-9 "; foreach (int pid in pids) { kill.StartInfo.Arguments += pid.ToString () + " "; } kill.StartInfo.UseShellExecute = false; kill.Start (); if (!kill.WaitForExit (1000 * 15 /* 15 seconds */)) throw new ApplicationException (string.Format ("The 'kill' process didn't exit in 15 seconds.")); } }
public void Beweeg(IEnumerable<Point> stack) { foreach (var point in stack.Reverse()) { _queue.Enqueue(point); } Start(); }
/// <summary> /// Initializes a new instance of the <see cref="ScriptReader"/> class. /// </summary> /// <param name="tokens">The tokens.</param> public ScriptReader(IEnumerable<string> tokens) { #region Contract // Contract.Requires<ArgumentNullException>(tokens != null); #endregion this.tokens = new Stack<string>(tokens.Reverse()); }
public static IArrayFunctionInstance ToInstance(IEnumerable<IFunctionInstance> enumerable) { IArrayFunctionInstance tail = ArrayTailFunction.Instance; foreach (IFunctionInstance t in enumerable.Reverse()) { tail = new ArrayHeadTailFunctionInstance (t, tail); } return tail; }
public static int Insert(this Collection<Instruction> collection, int index, IEnumerable<Instruction> instructions) { foreach (var instruction in instructions.Reverse()) { collection.Insert(index, instruction); } return index + instructions.Count(); }
private static IDictionary<string, object> NamedArgumentsToDictionary(IEnumerable<string> argumentNames, IEnumerable<object> args) { return argumentNames .Reverse() .Zip(args.Reverse(), (k, v) => new KeyValuePair<string, object>(k, v)) .Reverse() .ToDictionary(StringComparer.InvariantCultureIgnoreCase); }
internal static IDictionary<string, object> NamedArgumentsToDictionary(this InvokeMemberBinder binder, IEnumerable<object> args) { return binder.CallInfo.ArgumentNames .Reverse() .Zip(args.Reverse(), (k, v) => new KeyValuePair<string, object>(k, v)) .Reverse() .ToDictionary(); }
public static int CalculateSuccessInARow(PersonSetting personSetting, IEnumerable<BuildStatus> allActiveBuildDefinitionsOrderedChronoligically) { return allActiveBuildDefinitionsOrderedChronoligically .Reverse() .Where(i => i.RequestedBy == personSetting.RawName) .TakeWhile(i => i.BuildStatusEnum != BuildStatusEnum.Broken) .Count(); }
private static IDictionary<string, object> NamedArgumentsToDictionary(IEnumerable<string> argumentNames, IEnumerable<object> args) { return argumentNames .Reverse() .Zip(args.Reverse(), (k, v) => new KeyValuePair<string, object>(k, v)) .Reverse() .ToDictionary(); }
public static void Insert(this MethodBody body, int index, IEnumerable<Instruction> instructions) { instructions = instructions.Reverse(); foreach (var instruction in instructions) { body.Instructions.Insert(index, instruction); } }
public TMSimulation(TM machine, IEnumerable<Character> chars) { this.CurrentState = machine.BeginState; foreach (Character c in chars.Reverse()) { RStack.Push (c); } this.Fix (); }
public static IDictionary<string, object> ArgumentsToDictionary(this InvokeMemberBinder binder, IEnumerable<object> args) { return args.Reverse() .Zip(binder.CallInfo.ArgumentNames.Reverse().ExtendInfinite(), (v, k) => new KeyValuePair<string, object>(k, v)) .Reverse() .Select((kvp, i) => kvp.Key == null ? new KeyValuePair<string, object>("_" + i.ToString(), kvp.Value) : kvp) .ToDictionary(); }
public static Expression AggregateExpressionsIntoTuple (IEnumerable<Expression> expressions) { ArgumentUtility.CheckNotNull ("expressions", expressions); return expressions .Reverse () .Aggregate ((current, expression) => CreateTupleExpression (expression, current)); }
public void AddSupPops(IEnumerable<SubPop> pops) { this._speciesContainer.SuspendLayout(); foreach (SubPop sp in pops.Reverse()) { this.AddSubPop(sp); } this._speciesContainer.ResumeLayout(false); }
public ISymbolicDataAnalysisModel Backtransform(ISymbolicDataAnalysisModel model, IEnumerable<ITransformation> transformations, string targetVariable) { var symbolicModel = (ISymbolicDataAnalysisModel)model.Clone(); foreach (var transformation in transformations.Reverse()) { ApplyBacktransformation(transformation, symbolicModel.SymbolicExpressionTree, targetVariable); } return symbolicModel; }
/// <summary> /// Restores every window in the list that is minimized /// </summary> /// <param name="windows"> /// A <see cref="IEnumerable"/> /// </param> public static void RestoreWindows (IEnumerable<Window> windows) { foreach (Window window in windows.Reverse ()) { if (window.IsInViewport (window.Screen.ActiveWorkspace) && window.IsMinimized) { window.Unminimize (Gtk.Global.CurrentEventTime); System.Threading.Thread.Sleep (SleepTime); } } }