示例#1
0
        public SearchController(
            IDatabaseItemDao databaseItemDao,
            IPlayerItemDao playerItemDao,
            IDatabaseItemStatDao databaseItemStatDao,
            IItemSkillDao itemSkillDao,
            IBuddyItemDao buddyItemDao,
            StashManager stashManager,
            AugmentationItemRepo augmentationItemRepo
            )
        {
            this._dbItemDao              = databaseItemDao;
            this._playerItemDao          = playerItemDao;
            this._itemStatService        = new ItemStatService(databaseItemStatDao, itemSkillDao);
            this._itemPaginatorService   = new ItemPaginatorService(TakeSize);
            this._recipeService          = new RecipeService(databaseItemDao);
            this._costCalculationService = new CostCalculationService(playerItemDao, stashManager);
            this._buddyItemDao           = buddyItemDao;
            this._stashManager           = stashManager;
            this._augmentationItemRepo   = augmentationItemRepo;


            // Just make sure it writes .css/.html files before displaying anything to the browser
            //
            ItemHtmlWriter.ToJsonSerializeable(new List <PlayerHeldItem>()); // TODO: is this not a NOOP?
            JsBind.OnRequestItems += JsBind_OnRequestItems;

            // Return the ingredients for a given recipe
            JsBind.OnRequestRecipeIngredients += (sender, args) => {
                var recipeArgument = args as RequestRecipeArgument;
                var ingredients    = _recipeService.GetRecipeIngredients(recipeArgument?.RecipeRecord);
                _costCalculationService.Populate(ingredients);
                _costCalculationService.SetMod(_previousMod);

                _previousCallback = recipeArgument?.Callback;
                _previousRecipe   = recipeArgument?.RecipeRecord;
                Browser.SetRecipeIngredients(JsBind.Serialize(ingredients));
            };


            // Update the recipe when the stash has changed
            stashManager.StashUpdated += StashManagerOnStashUpdated;


            // Return the list of recipes
            JsBind.OnRequestRecipeList += (sender, args) => {
                var recipes = _recipeService.GetRecipeList();
                Browser.SetRecipes(JsBind.Serialize(recipes));
            };
        }