public QueueProcessor(IContainer factory)
        {
            _factory = factory;

            _itemProcessor = _factory.Resolve <IItemProcessor>();
            _queueItemDAL  = _factory.Resolve <IQueueItemDAL>();
        }
        public QueueProcessor(IContainer factory)
        {
            _factory = factory;

            _itemProcessor = _factory.Resolve<IItemProcessor>();
            _queueItemDAL = _factory.Resolve<IQueueItemDAL>();  
        }        
        /// <summary>
        /// Gets an item processor to handle updating the item's quality and sellIn days remaining
        /// </summary>
        /// <param name="item">The item to base the processor decision off of, uses the name of the item</param>
        /// <returns></returns>
        public static IItemProcessor GetItemProcessor(Item item)
        {
            IItemProcessor processor = null;

            switch (item.Name.ToLowerInvariant())
            {
            case "sulfuras, hand of ragnaros":
                processor = new LegendaryItemProcessor(item);
                break;

            case "aged brie":
                processor = new AgedBrieProcessor(item);
                break;

            case "backstage passes to a tafkal80etc concert":
                processor = new BackstagePassProcessor(item);
                break;

            case "conjured mana cake":
                processor = new ConjuredItemProcessor(item);
                break;

            default:
                processor = new CommonItemProcessor(item);
                break;
            }

            return(processor);
        }
Beispiel #4
0
 public void HandlePurchaseOrder(IPurchaseOrder purchaseOrder)
 {
     foreach (var item in purchaseOrder.ItemLines)
     {
         IItemProcessor itemProcessor = _ItemProcessorFactory.GetItemProcessor(item.Type);
         itemProcessor.HandlePurchaseOrderItem(purchaseOrder.CustomerId, item);
     }
 }
 public ItemController(UnitOfWork unitOfWork, IItemProcessor itemProcessor, IConfiguration configuration)
 {
     _unitOfWork    = unitOfWork;
     _itemProcessor = itemProcessor;
     _data          = string.Empty;
     _response      = new ResponseDto();
     _configuration = configuration;
 }
Beispiel #6
0
 public AuctionProcessor(DkpBotConfiguration configuration, AuctionState state, IItemProcessor itemProcessor, IDkpProcessor dkpProcessor, ILogger <AuctionProcessor> log)
 {
     ranks = configuration.ExpandedRanks;
     this.configuration = configuration;
     this.state         = state;
     this.itemProcessor = itemProcessor;
     this.dkpProcessor  = dkpProcessor;
     this.log           = log;
 }
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            IItemProcessor workThing = t as IItemProcessor;
            Thing          t2        = FindIngredient(pawn, workThing);

            return(new Job(SrvDefOf.SRV_FillProcessor, t, t2)
            {
                count = workThing.SpaceLeftForItem
            });
        }
Beispiel #8
0
 public AsyncCluster(int index, string title, IItemProcessor itemProcessor, IClusterItemExecuteLogger logger,
                     int maxItemInQueue)
 {
     eventReadyQueue =
         new BlockingCollection <IHaveClusterKeyItem>(maxItemInQueue);
     this.itemProcessor = itemProcessor;
     this.logger        = logger;
     Index = index;
     Title = title;
     Start();
 }
        public AddNewItemViewModel(string connectionString)
        {
            AddItemCommand       = new DelegateCommand(ExecuteAddItemCommand);
            CancelAddItemCommand = new DelegateCommand(ExecuteCancelAddItemCommand);

            _therapeuticClassProcessor = new TherapeuticClassProcessor(connectionString);
            _itemProcessor             = new ItemProcessor(connectionString);
            _inventoryProcessor        = new InventoryProcessor(connectionString);

            LoadTherapeuticClass();
            InitializeValues();
        }
        public void WhenItemNeverExpiresIsTrue_ThenSellInRemainsTheSame()
        {
            itemUnderTest.SellIn       = 4;
            itemUnderTest.NeverExpires = true;

            itemProcessor = new ItemProcessor(new List <IItem>()
            {
                itemUnderTest
            });
            itemProcessor.ProcessItems();

            Assert.Equal(4, itemUnderTest.SellIn);
        }
        private Thing FindIngredient(Pawn pawn, IItemProcessor workThing)
        {
            Predicate <Thing> validator;

            if (workThing.ItemValidator(pawn) != null)
            {
                validator = workThing.ItemValidator(pawn);
            }
            else
            {
                validator = (Thing x) => !x.IsForbidden(pawn) && pawn.CanReserve(x);
            }
            return(GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, workThing.InputRequest, PathEndMode.ClosestTouch, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), 9999f, validator));
        }
Beispiel #12
0
        public StreamReprocessor(IItemProcessor streamProcessor, IStreamStorage streamStorage)
        {
            if (streamProcessor == null)
            {
                throw new ArgumentNullException("streamProcessor");
            }

            if (streamStorage == null)
            {
                throw new ArgumentNullException("streamStorage");
            }

            this.streamProcessor = streamProcessor;
            this.streamStorage   = streamStorage;
        }
        public StreamReprocessor(IItemProcessor streamProcessor, IStreamStorage streamStorage)
        {
            if (streamProcessor == null)
            {
                throw new ArgumentNullException("streamProcessor");
            }

            if (streamStorage == null)
            {
                throw new ArgumentNullException("streamStorage");
            }

            this.streamProcessor = streamProcessor;
            this.streamStorage = streamStorage;
        }
        public void WhenDegredationFactorIsZero_ThenQualityRemainsTheSame()
        {
            itemUnderTest.DegredationRules.Add(new DegredationRule {
                DegredationValue = 0
            });
            itemUnderTest.Quality = 48;
            itemUnderTest.SellIn  = 9;

            itemProcessor = new ItemProcessor(new List <IItem>()
            {
                itemUnderTest
            });
            itemProcessor.ProcessItems();

            Assert.Equal(48, itemUnderTest.Quality);
            Assert.Equal(8, itemUnderTest.SellIn);
        }
        public void AtTheEndOfTheDay_SystemLowersBothValuesForItem()
        {
            itemUnderTest.DegredationRules.Add(new DegredationRule {
                DegredationValue = 1
            });
            itemUnderTest.Quality = 2;
            itemUnderTest.SellIn  = 3;

            itemProcessor = new ItemProcessor(new List <IItem>()
            {
                itemUnderTest
            });
            itemProcessor.ProcessItems();

            Assert.Equal(1, itemUnderTest.Quality);
            Assert.Equal(2, itemUnderTest.SellIn);
        }
        public void OnceSellByDateIsLessThanZero_ThenQualityDegradesTwiceAsFast()
        {
            itemUnderTest.DegredationRules.Add(new DegredationRule {
                DegredationValue = 1
            });
            itemUnderTest.SellIn  = -1;
            itemUnderTest.Quality = 10;

            itemProcessor = new ItemProcessor(new List <IItem>()
            {
                itemUnderTest
            });
            itemProcessor.ProcessItems();

            Assert.Equal(8, itemUnderTest.Quality);
            Assert.Equal(-2, itemUnderTest.SellIn);
        }
        public void WhenDegredationFactorIsPositive_AndOnceSellByDateIsLessThanZero_ThenQualityDecreasesByDegredationFactorAndTwiceAsFast()
        {
            itemUnderTest.DegredationRules.Add(new DegredationRule {
                DegredationValue = 2
            });
            itemUnderTest.Quality = 5;
            itemUnderTest.SellIn  = -1;

            itemProcessor = new ItemProcessor(new List <IItem>()
            {
                itemUnderTest
            });
            itemProcessor.ProcessItems();

            Assert.Equal(1, itemUnderTest.Quality);
            Assert.Equal(-2, itemUnderTest.SellIn);
        }
        public void WhenDegredationFactorIsNegative_ThenQualityIncreasesByDegredationFactor()
        {
            itemUnderTest.DegredationRules.Add(new DegredationRule {
                DegredationValue = -2
            });
            itemUnderTest.Quality = 10;
            itemUnderTest.SellIn  = 9;

            itemProcessor = new ItemProcessor(new List <IItem>()
            {
                itemUnderTest
            });
            itemProcessor.ProcessItems();

            Assert.Equal(12, itemUnderTest.Quality);
            Assert.Equal(8, itemUnderTest.SellIn);
        }
        public void WhenQualityIsAtFifty_AndQualityIncreased_ThenQualityRemainsAtFifty()
        {
            itemUnderTest.DegredationRules.Add(new DegredationRule {
                DegredationValue = -1
            });
            itemUnderTest.Quality = 55;
            itemUnderTest.SellIn  = 9;

            itemProcessor = new ItemProcessor(new List <IItem>()
            {
                itemUnderTest
            });
            itemProcessor.ProcessItems();

            Assert.Equal(50, itemUnderTest.Quality);
            Assert.Equal(8, itemUnderTest.SellIn);
        }
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            IItemProcessor workThing = t as IItemProcessor;

            if (workThing == null || workThing.Finished || workThing.SpaceLeftForItem <= 0)
            {
                return(false);
            }
            if (!workThing.TemperatureAcceptable)
            {
                JobFailReason.Is(Static.TemperatureTrans);
                return(false);
            }

            Building_Smoker smoker = t as Building_Smoker;

            if (smoker != null)
            {
                if (smoker.Finished)
                {
                    return(false);
                }
                if (!smoker.CanAddFood)
                {
                    JobFailReason.Is(Static.SmokerLocked);
                    return(false);
                }
            }

            if (t.IsForbidden(pawn) || !pawn.CanReserveAndReach(t, PathEndMode.Touch, pawn.NormalMaxDanger(), 1, -1, null, forced))
            {
                return(false);
            }
            if (pawn.Map.designationManager.DesignationOn(t, DesignationDefOf.Deconstruct) != null)
            {
                return(false);
            }
            if (FindIngredient(pawn, workThing) == null)
            {
                JobFailReason.Is(Static.NoIngredient);
                return(false);
            }
            return(!t.IsBurning());
        }
        public IItemProcessor GetItemProcessor(ItemLineRequest itemLine)
        {
            IItemProcessor itemProcessor = null;;

            switch (itemLine.Type)
            {
            case ItemLineType.Product:
                itemProcessor = GetProductItemProcessor(itemLine);
                break;

            case ItemLineType.Membership:
                itemProcessor = GetMembershipItemProcessor(itemLine);
                break;

            default:
                throw new Exception("Invalid Line Item Type. Could not get item processor");
                break;
            }
            return(itemProcessor);
        }
        public void WhenThereAreThreeDaysOrLess_ThenQualityIncreasesByThree()
        {
            itemUnderTest.Quality = 4;
            itemUnderTest.SellIn  = 3;

            var rule1 = new DegredationRule
            {
                DegredationValue = -2,
                SellInThreshold  = 10
            };

            itemUnderTest.DegredationRules.Add(rule1);

            var rule2 = new DegredationRule
            {
                DegredationValue = -3,
                SellInThreshold  = 5
            };

            itemUnderTest.DegredationRules.Add(rule2);

            var rule3 = new DegredationRule
            {
                DegredationValue = 0,
                DegredationType  = DegredationType.Absolute,
                SellInThreshold  = -1
            };

            itemUnderTest.DegredationRules.Add(rule3);

            itemProcessor = new ItemProcessor(new List <IItem>()
            {
                itemUnderTest
            });
            itemProcessor.ProcessItems();

            Assert.Equal(7, itemUnderTest.Quality);
        }
        public void OnceSellByDateIsLessThanZero_ThenQualityDropsToZero()
        {
            itemUnderTest.Quality = 4;
            itemUnderTest.SellIn  = -1;

            var rule1 = new DegredationRule
            {
                DegredationValue = -2,
                SellInThreshold  = 10
            };

            itemUnderTest.DegredationRules.Add(rule1);

            var rule2 = new DegredationRule
            {
                DegredationValue = -3,
                SellInThreshold  = 5
            };

            itemUnderTest.DegredationRules.Add(rule2);

            var rule3 = new DegredationRule
            {
                DegredationValue = 0,
                DegredationType  = DegredationType.Absolute,
                SellInThreshold  = -1
            };

            itemUnderTest.DegredationRules.Add(rule3);

            itemProcessor = new ItemProcessor(new List <IItem>()
            {
                itemUnderTest
            });
            itemProcessor.ProcessItems();

            Assert.Equal(0, itemUnderTest.Quality);
        }
        public MainWindowViewModel()
        {
            //Initialize commands
            SalesSearchCommand         = new DelegateCommand(ExecuteSalesSearchCommand, CanExecuteSalesSearchCommand);
            ShoppingListAddItemCommand = new DelegateCommand(ExecuteShoppingListAddItemCommand);
            ShoppingListConfirmCommand = new DelegateCommand(ExecuteShoppingListConfirmCommand);
            ShoppingListCancelCommand  = new DelegateCommand(ExecuteShoppingListCancelCommand);
            InventorySearchCommand     = new DelegateCommand(ExecuteInventorySearchCommand);
            AddInventoryItemCommand    = new DelegateCommand(ExecuteAddInventoryItemCommand);
            AddNewItemCommand          = new DelegateCommand(ExecuteAddNewItemCommand);

            //Initialize processors
            _itemProcessor             = new ItemProcessor(_connectionString);
            _inventoryProcessor        = new InventoryProcessor(_connectionString);
            _therapeuticClassProcessor = new TherapeuticClassProcessor(_connectionString);

            //Initialize values
            AddInventoryExpiryDate        = DateTime.Now;
            AddInventoryManufacturingDate = DateTime.Now;
            ShoppingList = new ObservableCollection <Item>();

            LoadAvailableTherapeuticClass();
        }
 public CItemProcessor(IItemProcessor next) : base("C", next)
 {
 }
 /// <summary>
 /// Custom constructor using and itemprocessor and an itemwriter.
 /// </summary>
 /// <param name="itemProcessor"></param>
 /// <param name="itemWriter"></param>
 public SimpleChunkProcessor(IItemProcessor <TIn, TOut> itemProcessor, IItemWriter <TOut> itemWriter)
 {
     ItemProcessor = itemProcessor;
     ItemWriter    = itemWriter;
 }
Beispiel #27
0
 public AbstractItemProcessor(string ItemType, IItemProcessor next)
 {
     this.Next     = next;
     this.ItemType = ItemType;
 }
Beispiel #28
0
 private AItemProcessor CreateSut(IItemProcessor next)
 {
     return(new AItemProcessor(next));
 }
Beispiel #29
0
 public SomeService(IItemProcessor processor)
 {
     this.processor = processor;
 }
Beispiel #30
0
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            IItemProcessor workThing = t as IItemProcessor;

            return(workThing != null && workThing.Finished && !t.IsBurning() && !t.IsForbidden(pawn) && pawn.CanReserveAndReach(t, PathEndMode.Touch, pawn.NormalMaxDanger(), 1, -1, null, forced));
        }
 public DItemProcessor(IItemProcessor next) : base("D", next)
 {
 }
Beispiel #32
0
 public Checkout(IItemProcessor itemProcessor)
 {
     _itemProcessor = itemProcessor;
 }