private void ResolveAddition(string expression) { foreach (var addition in expression.Split("+", StringSplitOptions.RemoveEmptyEntries)) { if (addition.Contains("/")) { ResolveDivision(expression); if (TryDivide(Divisions, out string resultOfDivision)) { Additions.Add(resultOfDivision); } else { throw new Exception(resultOfDivision); } } else if (addition.Contains("*")) { Additions.Add(Multiply(addition.Split("*", StringSplitOptions.RemoveEmptyEntries))); } else { Additions.Add(addition); } } }
/// <summary> /// Result of a Difference Lines operation /// </summary> /// <param name="items"></param> /// <param name="leftValue"></param> /// <param name="rightValue"></param> public LineDifferenceResult(Item[] items, string leftValue, string rightValue) { var aLines = leftValue.Split('\n'); var bLines = rightValue.Split('\n'); var n = 0; for (var fdx = 0; fdx < items.Length; fdx++) { var aItem = items[fdx]; while ((n < aItem.StartB) && (n < bLines.Length)) { Unchanged.Add(bLines[n]); n++; } for (var m = 0; m < aItem.DeletedA; m++) { Deletions.Add(aLines[aItem.StartA + m]); } while (n < aItem.StartB + aItem.InsertedB) { Additions.Add(bLines[n]); n++; } while (n < bLines.Length) { Unchanged.Add(bLines[n]); n++; } } }
public DishWithAddition(int id, string name, double price, string description, int dishGroupId, List <Addition> additions) : base(id, name, price, description, dishGroupId) { foreach (var add in additions) { Additions.Add(add); } }
protected void DeferAdd(ITransient other) { if (other == null) { return; } Deletions.RemoveRef(other); Additions.Add(other); }
public void Remove(ITransient other) { if (other == null) { return; } Additions.RemoveRef(other); Deletions.Add(other); }
public void Clear() { Additions.Clear(); foreach (var tr in Contents) { Deletions.Add(tr); } PerformRemoves(); }
public Order Add(Product addition) { var orderAddition = Container.NewTransientInstance <OrderAddition>(); orderAddition.Order = this; orderAddition.Product = addition; Container.Persist(ref orderAddition); Price += orderAddition.Product.Price; Additions.Add(orderAddition); return(this); }
private void PerformAdds() { foreach (var tr in Additions) { _contents.Add(tr); Verbose(30, $"Adding {tr} to {this}"); tr.Completed += Remove; Added?.Invoke(this, tr); } Additions.Clear(); }
public void Add(params ITransient[] others) { foreach (var other in others) { if (other == null) { continue; } Deletions.RemoveRef(other); Additions.Add(other); } }
internal QBSession(QBSessionFactory sessionFactory, string qbXmlVersion, string ticket) { _log.InfoFormat("Opening Session Ticket {0}", ticket); _sessionFactory = sessionFactory; _qbXmlVersion = qbXmlVersion; _ticket = ticket; IsOpen = true; Query = new Queries(this); Report = new Reports.Reports(this); Add = new Additions(this); Modify = new Modifications(this); }
public void Save(Additions addition) { if (addition.Id == 0) { _dbContext.Additions.Add(addition); } else { _dbContext.Entry(addition).State = EntityState.Modified; } _dbContext.SaveChanges(); }
public Order Remove(Product addition) { var orderAddition = Additions.FirstOrDefault(a => a.Product == addition); if (orderAddition == null) { return(this); } Price -= orderAddition.Product.Price; Container.DisposeInstance(orderAddition); Additions.Remove(orderAddition); return(this); }
private void PerformAdds() { foreach (var tr in Additions) { _contents.Add(tr); tr.Completed += Remove; if (Added != null) { Added(this, tr); } } Additions.Clear(); }
/// <summary> /// Combines two arrays and returns a new array containing both values /// </summary> /// <typeparam name="ArrayType">Type of the data in the array</typeparam> /// <param name="Array1">Array 1</param> /// <param name="Additions">Arrays to concat onto the first item</param> /// <returns>A new array containing both arrays' values</returns> public static ArrayType[] Concat <ArrayType>(this ArrayType[] Array1, params ArrayType[][] Additions) { Contract.Requires <ArgumentNullException>(Array1 != null, "Array1"); Contract.Requires <ArgumentNullException>(Additions != null, "Additions"); Contract.Requires <ArgumentNullException>(Contract.ForAll(Additions, x => x != null), "Additions"); ArrayType[] Result = new ArrayType[Array1.Length + Additions.Sum(x => x.Length)]; int Offset = Array1.Length; Array.Copy(Array1, 0, Result, 0, Array1.Length); for (int x = 0; x < Additions.Length; ++x) { Array.Copy(Additions[x], 0, Result, Offset, Additions[x].Length); Offset += Additions[x].Length; } return(Result); }
/// <summary> /// Adds any addition parameters. /// </summary> /// <param name="command">The command.</param> private bool AddAdditionParameters(IDbCommand command) { bool haveAdditions = Additions.Count != 0; if (haveAdditions) { foreach (var pair in Additions.OrderBy(kvp => kvp.Key)) { string typeName = GetTypeName(pair.Key); command.AddTableValuedParameter(string.Format("@merge{0}", typeName), pair.Value); } } return(haveAdditions); }
public MathContainer SetAddition(AdditionConfig config) { if (config == null) { config = new AdditionConfig(); config.SetDefault(); } config.Repaire(); for (var i = 0; i < config.Times; i++) { Additions.Add(GenerateAddition(config)); } return(this); }
public bool Add(T item, OperationDetails od) { var operation = new Operation <T>(item, od); if (Contains(item)) { return(false); } if (Additions.Add(operation)) { _setRisk(od.Risk); return(true); } return(false); }
private void AddRemove() { DataLock.WaitOne(); foreach (InstanceData t in Additions) { Data.Add(t); } foreach (InstanceData t in Removals) { Data.Remove(t); } Additions.Clear(); Removals.Clear(); DataLock.ReleaseMutex(); }
public PN_Counter Add(int value, Guid nodeId) { var element = Additions.FirstOrDefault(e => e.Node.Id == nodeId); if (element is null) { element = new CounterElement(value, nodeId); } else { element.Add(value); } var additions = Additions.Where(e => e.Node.Id != nodeId).ToImmutableHashSet(); additions = additions.Add(element); return(new PN_Counter(additions, Subtractions)); }
public void HandleAddRemoves() { AdditionMutex.WaitOne(); foreach (GameComponent component in Additions) { AddComponentImmediate(component); } Additions.Clear(); AdditionMutex.ReleaseMutex(); RemovalMutex.WaitOne(); foreach (GameComponent component in Removals) { RemoveComponentImmediate(component); } Removals.Clear(); RemovalMutex.ReleaseMutex(); }
private void ButtonDeleteClick(object sender, EventArgs e) { if (listBoxFileNames.Items.Count == 0) { return; } int oldComboBoxIndex = comboBoxTexts.SelectedIndex; string target = GetSelectedFileName(); XmlNode node = _compareDoc.DocumentElement.SelectSingleNode("Item[.='" + target + "']"); if (node != null) { _compareDoc.DocumentElement.RemoveChild(node); if (Additions != null && Additions.Count > 0) { for (int i = Additions.Count - 1; i >= 0; i--) { if (Additions[i].Name == target) { Additions.RemoveAt(i); Refill(Additions); break; } } } Refill(Additions); if (Additions == null || Additions.Count == 0) { if (oldComboBoxIndex < comboBoxTexts.Items.Count) { comboBoxTexts.SelectedIndex = oldComboBoxIndex; } } } }
private GitProcessDiff( string start, string end, string?since, Additions additions, Deletions deletions, string key, string?link, string organization, DateTimeOffset createdAt, string email ) { _start = start; _end = end; _since = since; _additions = additions; _deletions = deletions; _key = key; _link = link; _organization = organization; _createdAt = createdAt; _email = email; }
public void AddComponent(GameComponent component) { AdditionMutex.WaitOne(); Additions.Add(component); AdditionMutex.ReleaseMutex(); }
private void ButtonDeleteClick(object sender, EventArgs e) { if (listBoxFileNames.Items.Count == 0) { return; } int oldComboBoxIndex = comboBoxTexts.SelectedIndex; string target = GetSelectedFileName(); if (_binOcrDb != null) { BinaryOcrBitmap bob = GetSelectedBinOcrBitmap(); if (bob != null) { if (bob.ExpandCount > 0) { _binOcrDb.CompareImagesExpanded.Remove(bob); } else { _binOcrDb.CompareImages.Remove(bob); } if (Additions != null && Additions.Count > 0) { for (int i = Additions.Count - 1; i >= 0; i--) { if (Additions[i].Name == bob.Key) { Additions.RemoveAt(i); Refill(Additions); break; } } } Refill(Additions); } if (oldComboBoxIndex >= 0 && oldComboBoxIndex < comboBoxTexts.Items.Count) { comboBoxTexts.SelectedIndex = oldComboBoxIndex; } return; } XmlNode node = _compareDoc.DocumentElement.SelectSingleNode("Item[.='" + target + "']"); if (node != null) { _compareDoc.DocumentElement.RemoveChild(node); if (Additions != null && Additions.Count > 0) { for (int i = Additions.Count - 1; i >= 0; i--) { if (Additions[i].Name == target) { Additions.RemoveAt(i); Refill(Additions); break; } } } Refill(Additions); if (Additions == null || Additions.Count == 0) { if (oldComboBoxIndex < comboBoxTexts.Items.Count) { comboBoxTexts.SelectedIndex = oldComboBoxIndex; } } } }
public void Add(InstanceData data) { DataLock.WaitOne(); Additions.Add(data); DataLock.ReleaseMutex(); }
public override int GetHashCode() { unchecked { return((Url != null ? Url.GetHashCode() : 0) ^ (HtmlUrl != null ? HtmlUrl.GetHashCode() : 0) ^ (DiffUrl != null ? DiffUrl.GetHashCode() : 0) ^ (PatchUrl != null ? PatchUrl.GetHashCode() : 0) ^ (IssueUrl != null ? IssueUrl.GetHashCode() : 0) ^ (Number != null ? Number.GetHashCode() : 0) ^ (State != null ? State.GetHashCode() : 0) ^ (Title != null ? Title.GetHashCode() : 0) ^ (Body != null ? Body.GetHashCode() : 0) ^ (BodyHtml != null ? BodyHtml.GetHashCode() : 0) ^ (CreatedAt != null ? CreatedAt.GetHashCode() : 0) ^ (UpdatedAt != null ? UpdatedAt.GetHashCode() : 0) ^ (ClosedAt != null ? ClosedAt.GetHashCode() : 0) ^ (MergedAt != null ? MergedAt.GetHashCode() : 0) ^ (Head != null ? Head.GetHashCode() : 0) ^ (Base != null ? Base.GetHashCode() : 0) ^ (User != null ? User.GetHashCode() : 0) ^ (Merged != null ? Merged.GetHashCode() : 0) ^ (Mergeable != null ? Mergeable.GetHashCode() : 0) ^ (MergedBy != null ? MergedBy.GetHashCode() : 0) ^ (Comments != null ? Comments.GetHashCode() : 0) ^ (Commits != null ? Commits.GetHashCode() : 0) ^ (Additions != null ? Additions.GetHashCode() : 0) ^ (Deletions != null ? Deletions.GetHashCode() : 0) ^ (ChangedFiles != null ? ChangedFiles.GetHashCode() : 0)); } }
/* * Usuwa dodatek i aktualizuje cene * @param {Addition} add - Dodatek do dania * @return void; */ public void Remove(Addition add) { Additions.Remove(add); Price -= add.Price; }
/* * Dodaje dodatek do dania aktualizuje cene * @param {Addition} add - Dodatek do dania * @return void; */ public void Add(Addition add) { Additions.Add(add); Price += add.Price; }
public string ValidateRemove(Product addition) { var orderAddition = Additions.FirstOrDefault(a => a.Product == addition); return(orderAddition == null ? "No such addition" : null); }
public override int GetHashCode() { unchecked { return((Filename != null ? Filename.GetHashCode() : 0) ^ (Additions != null ? Additions.GetHashCode() : 0) ^ (Deletions != null ? Deletions.GetHashCode() : 0) ^ (Changes != null ? Changes.GetHashCode() : 0) ^ (Status != null ? Status.GetHashCode() : 0) ^ (RawUrl != null ? RawUrl.GetHashCode() : 0) ^ (BlobUrl != null ? BlobUrl.GetHashCode() : 0) ^ (Patch != null ? Patch.GetHashCode() : 0) ^ (ContentsUrl != null ? ContentsUrl.GetHashCode() : 0)); } }