Example #1
0
 protected override void GenerateBehaviour()
 {
     if (_itemPosition >= 0 && _itemPosition < cache.cacheTypes.Length)
     {
         T item = cache.Get(_itemPosition);
         item.gameObject.SetActive(true);
         item.transform.parent = transform;
         SpawnItem(item);
     }
     _itemPosition = -1;
 }
Example #2
0
        public PartialViewResult MenuCategoryEvents()
        {
            //without interface use : HttpContext.Cache.Add("Some value");
            ICache abstractCache = new AbstractCache();

            List <GamingEvent>   randomEvents;
            List <CategoryEvent> gameEventsCategories;

            if (abstractCache.IsSet(ConfigurationManager.AppSettings["RandomEventOffer"]))
            {
                randomEvents = abstractCache.Get(ConfigurationManager.AppSettings["RandomEventOffer"]) as List <GamingEvent>;
            }
            else
            {
                randomEvents = context.GamingEvents.OrderByDescending(g => Guid.NewGuid()).Take(3).ToList();
                abstractCache.Set(ConfigurationManager.AppSettings["RandomEventOffer"], randomEvents, 60);
            }

            if (abstractCache.IsSet(ConfigurationManager.AppSettings["GameEventsCategories"]))
            {
                gameEventsCategories = abstractCache.Get(ConfigurationManager.AppSettings["GameEventsCategories"]) as List <CategoryEvent>;
            }
            else
            {
                gameEventsCategories = context.CategoryEvents.ToList();
                abstractCache.Set(ConfigurationManager.AppSettings["GameEventsCategories"], gameEventsCategories, 1440);
            }


            var vm = new GameEventCategoryMenuViewModel()
            {
                GamingEvents   = randomEvents,
                CategoryEvents = gameEventsCategories
            };

            return(PartialView("_MenuCategoryGameEvents", vm));
        }