コード例 #1
0
        private IEnumerable <string> GetMessage(BalanceTables balanceTables)
        {
            var result = new List <string>();

            var causesCollection = balanceTables.CausesFailureIncludedNested;

            if (!causesCollection.Any())
            {
                return(result);
            }

            if (causesCollection.IsContainsOnly <CauseNoCommandsForExecute>())
            {
                result.Add("Already is balanced!");
            }

            result.AddRange(causesCollection.OfType <CauseNoRequiredAmountInSourceInventory>().
                            Select(cause => $"In the inventory of {cause.InventoryFrom.NameInstance} there are not enough ({cause.AmountWantTake} - {cause.AmountCanTake})"
                                   + $" {cause.AmountWantTake - cause.AmountCanTake} coins!"));

            result.AddRange(causesCollection.OfType <CauseTargetInventoryIsOverflow>().Select(cause =>
                                                                                              $"Inventory {cause.Inventory} is full!"));

            return(result);
        }
コード例 #2
0
        public void Display(BalanceTables balanceTables)
        {
            var message = GetMessage(balanceTables);

            ShowMessage(message);
        }