예제 #1
0
 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);
         }
     }
 }
예제 #2
0
            /// <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++;
                    }
                }
            }
예제 #3
0
 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);
     }
 }
예제 #4
0
        protected void DeferAdd(ITransient other)
        {
            if (other == null)
            {
                return;
            }

            Deletions.RemoveRef(other);
            Additions.Add(other);
        }
예제 #5
0
        public void Remove(ITransient other)
        {
            if (other == null)
            {
                return;
            }

            Additions.RemoveRef(other);
            Deletions.Add(other);
        }
예제 #6
0
        public void Clear()
        {
            Additions.Clear();

            foreach (var tr in Contents)
            {
                Deletions.Add(tr);
            }

            PerformRemoves();
        }
예제 #7
0
        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);
        }
예제 #8
0
        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();
        }
예제 #9
0
        public void Add(params ITransient[] others)
        {
            foreach (var other in others)
            {
                if (other == null)
                {
                    continue;
                }

                Deletions.RemoveRef(other);
                Additions.Add(other);
            }
        }
예제 #10
0
        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();
        }
예제 #12
0
        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);
        }
예제 #13
0
        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);
        }
예제 #15
0
        /// <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);
        }
예제 #16
0
        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);
        }
예제 #18
0
        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();
        }
예제 #19
0
        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));
        }
예제 #20
0
        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();
        }
예제 #21
0
        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;
                    }
                }
            }
        }
예제 #22
0
 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;
 }
예제 #23
0
 public void AddComponent(GameComponent component)
 {
     AdditionMutex.WaitOne();
     Additions.Add(component);
     AdditionMutex.ReleaseMutex();
 }
예제 #24
0
        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;
                    }
                }
            }
        }
예제 #25
0
 public void Add(InstanceData data)
 {
     DataLock.WaitOne();
     Additions.Add(data);
     DataLock.ReleaseMutex();
 }
예제 #26
0
 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));
     }
 }
예제 #27
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;
 }
예제 #28
0
 /*
  * 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;
 }
예제 #29
0
        public string ValidateRemove(Product addition)
        {
            var orderAddition = Additions.FirstOrDefault(a => a.Product == addition);

            return(orderAddition == null ? "No such addition" : null);
        }
예제 #30
0
 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));
     }
 }