Exemple #1
0
        private async Task SetIncrement()
        {
            try
            {
                Convert.ToDecimal(SelectedIncrement?.Cash, CultureInfo.InvariantCulture);
                Convert.ToDecimal(SelectedIncrement?.Credit, CultureInfo.InvariantCulture);
            }
            catch (Exception ex)
            {
                // Eating exception when prices are not in correct format
                return;
            }

            var result = await _fuelPriceBusinessLogic.SetPriceIncrement(SelectedIncrement?.ToEntity(), _taxExempt);

            var model = result?.Price.ToModel();
            var data  = Increments.FirstOrDefault(x => x.Row == result?.Price.Row);
            var index = Increments.IndexOf(data);

            if (index != -1)
            {
                Increments[index] = model;
            }

            MessengerInstance.Send(new FuelPriceReportMessage {
                Report = result?.Report.ReportContent
            });
        }
        public Updates <T> Increment(Expression <Func <T, object> > propertyExpression, object value)
        {
            var update = Update <T> .Property(propertyExpression, value);

            Increments = Increments ?? new List <Update <T> >();
            Increments.Add(update);
            return(this);
        }
Exemple #3
0
        public PNCounter ResetDelta()
        {
            if (Increments.Delta == null && Decrements.Delta == null)
            {
                return(this);
            }

            return(new PNCounter(Increments.ResetDelta(), Decrements.ResetDelta()));
        }
Exemple #4
0
        private PNCounter Change(UniqueAddress key, long delta)
        {
            if (delta > 0)
            {
                return(new PNCounter(Increments.Increment(key, (ulong)delta), Decrements));
            }
            if (delta < 0)
            {
                return(new PNCounter(Increments, Decrements.Increment(key, (ulong)(-delta))));
            }

            return(this);
        }
Exemple #5
0
        private PNCounter Change(UniqueAddress key, BigInteger delta)
        {
            if (delta > 0)
            {
                return(new PNCounter(Increments.Increment(key, delta), Decrements));
            }
            if (delta < 0)
            {
                return(new PNCounter(Increments, Decrements.Increment(key, -delta)));
            }

            return(this);
        }
Exemple #6
0
        /// <summary>
        /// Print the object's XML to the XmlWriter.
        /// </summary>
        /// <param name="objWriter">XmlTextWriter to write with.</param>
        /// <param name="objCulture">Culture in which to print.</param>
        /// <param name="strLanguageToPrint">Language in which to print</param>
        public void Print(XmlTextWriter objWriter, CultureInfo objCulture, string strLanguageToPrint)
        {
            objWriter.WriteStartElement("lifestyle");
            objWriter.WriteElementString("name", CustomName);
            objWriter.WriteElementString("cost", Cost.ToString(_objCharacter.Options.NuyenFormat, objCulture));
            objWriter.WriteElementString("totalmonthlycost", TotalMonthlyCost.ToString(_objCharacter.Options.NuyenFormat, objCulture));
            objWriter.WriteElementString("totalcost", TotalCost.ToString(_objCharacter.Options.NuyenFormat, objCulture));
            objWriter.WriteElementString("dice", Dice.ToString(objCulture));
            objWriter.WriteElementString("multiplier", Multiplier.ToString(_objCharacter.Options.NuyenFormat, objCulture));
            objWriter.WriteElementString("months", Increments.ToString(objCulture));
            objWriter.WriteElementString("purchased", Purchased.ToString());
            objWriter.WriteElementString("type", StyleType.ToString());
            objWriter.WriteElementString("increment", IncrementType.ToString());
            objWriter.WriteElementString("sourceid", SourceID.ToString("D"));
            objWriter.WriteElementString("bonuslp", BonusLP.ToString(objCulture));
            string strBaseLifestyle = string.Empty;

            // Retrieve the Advanced Lifestyle information if applicable.
            if (!string.IsNullOrEmpty(BaseLifestyle))
            {
                XmlNode objXmlAspect = GetNode();
                if (objXmlAspect != null)
                {
                    strBaseLifestyle = objXmlAspect["translate"]?.InnerText ?? objXmlAspect["name"]?.InnerText ?? strBaseLifestyle;
                }
            }

            objWriter.WriteElementString("baselifestyle", strBaseLifestyle);
            objWriter.WriteElementString("trustfund", TrustFund.ToString());
            objWriter.WriteElementString("source", CommonFunctions.LanguageBookShort(Source, strLanguageToPrint));
            objWriter.WriteElementString("page", DisplayPage(strLanguageToPrint));
            objWriter.WriteStartElement("qualities");

            // Retrieve the Qualities for the Advanced Lifestyle if applicable.
            foreach (LifestyleQuality objQuality in LifestyleQualities)
            {
                objQuality.Print(objWriter, objCulture, strLanguageToPrint);
            }
            // Retrieve the free Grids for the Advanced Lifestyle if applicable.
            foreach (LifestyleQuality objQuality in FreeGrids)
            {
                objQuality.Print(objWriter, objCulture, strLanguageToPrint);
            }
            objWriter.WriteEndElement();
            if (_objCharacter.Options.PrintNotes)
            {
                objWriter.WriteElementString("notes", Notes);
            }
            objWriter.WriteEndElement();
        }
Exemple #7
0
 public PNCounter Merge(PNCounter other) =>
 new PNCounter(Increments.Merge(other.Increments), Decrements.Merge(other.Decrements));
Exemple #8
0
 /// <inheritdoc/>
 public override int GetHashCode() => Increments.GetHashCode() ^ Decrements.GetHashCode();
Exemple #9
0
 public PNCounter PruningCleanup(Cluster.UniqueAddress removedNode) =>
 new PNCounter(Increments.PruningCleanup(removedNode), Decrements.PruningCleanup(removedNode));
Exemple #10
0
 public PNCounter Prune(Cluster.UniqueAddress removedNode, Cluster.UniqueAddress collapseInto) =>
 new PNCounter(Increments.Prune(removedNode, collapseInto), Decrements.Prune(removedNode, collapseInto));
Exemple #11
0
 public bool NeedPruningFrom(Cluster.UniqueAddress removedNode) =>
 Increments.NeedPruningFrom(removedNode) || Decrements.NeedPruningFrom(removedNode);
        protected override void CalculateAxisItems(Type propertyType, ref double minValue, ref double maxValue)
        {
            if (propertyType == typeof(DateTime))
            {
                throw new NotImplementedException("AdaptableIncrementAxis is not supported for DateTime." +
                                                  "Use AdaptableDateTimeAxis instead.");
            }

            if (Increments == null || Increments.Count == 0)
            {
                throw new ArgumentException("Increments collection must contain have at least one item");
            }

            if (MaximumItems < 2)
            {
                throw new ArgumentException("MaximumItems must be at least 2");
            }

            if (minValue == maxValue)
            {
                minValue -= 1;
                maxValue += 1;
            }

            // Copy the increments to an array and sort them
            double[] increments = new double[Increments.Count];
            Increments.CopyTo(increments, 0);
            Array.Sort(increments);

            // Initialize IncrementFinder
            IncrementFinder finder = new IncrementFinder(increments, minValue, maxValue);

            // Try to find the optimum increment
            while (true)
            {
                double increment = finder.Increment;

                if (finder.TickCount == MaximumItems)
                {
                    break;
                }

                else if (finder.TickCount > MaximumItems)
                {
                    finder.BumpUp();

                    if (finder.TickCount <= MaximumItems)
                    {
                        break;
                    }
                }

                else if (finder.TickCount < MaximumItems)
                {
                    finder.KickDown();

                    if (finder.TickCount > MaximumItems)
                    {
                        finder.BumpUp();
                        break;
                    }
                }
            }

            // Now we're ready to find the axis items
            double tickLength = Length / (finder.MaxFactor - finder.MinFactor);

            // Calculate AxisItem objects and add to collection
            for (int factor = finder.MinFactor; factor <= finder.MaxFactor; factor++)
            {
                AxisItem axisItem = new AxisItem()
                {
                    Item   = ConvertFromDouble(factor * finder.Increment, propertyType),
                    Offset = (factor - finder.MinFactor) * tickLength
                };

                if (IsFlipped)
                {
                    axisItem.Offset = Length - axisItem.Offset;
                }

                AxisItems.Add(axisItem);
            }

            // New minValue and maxValue for return
            minValue = finder.Increment * finder.MinFactor;
            maxValue = finder.Increment * finder.MaxFactor;
        }