Пример #1
0
        public IEnumerable <CardModel> Search(string searchTerm)
        {
            SearchCardsQuery    searchCardsQuery = new SearchCardsQuery(searchTerm);
            IEnumerable <ICard> icards           = _cardCache.Query(searchCardsQuery);
            //IEnumerable<ICard> icards = _cardCache.Query(new SearchCardsQuery(searchTerm));
            IEnumerable <CardModel> cards = Mapper.Map <IEnumerable <ICard>, IEnumerable <CardModel> >(icards);

            return(cards);
        }
        public CardsMappingProfile(IHearthstoneCardCache hearthstoneCardCache)
        {
            _hearthstoneCardCache = hearthstoneCardCache;

            CreateMap <ICard, CardModel>()
            .Include <Card, CardModel>()
            .Include <MinionCard, MinionModel>()
            .Include <WeaponCard, WeaponModel>()
            .Include <SpellCard, SpellModel>()
            .Include <HeroCard, HeroModel>()
            .ForMember(m => m.PlayerClass,
                       opt => opt.ResolveUsing(m => _hearthstoneCardCache.Query(new FindHeroCardQuery(m.PlayerClass))))
            .ForMember(m => m.PlayerClassText, opt =>
            {
                opt.NullSubstitute("Neutral");
                opt.MapFrom(m => m.PlayerClass);
            })
            ;

            CreateMap <Card, CardModel>();
            CreateMap <MinionCard, MinionModel>();
            CreateMap <WeaponCard, WeaponModel>();
            CreateMap <SpellCard, SpellModel>();
            CreateMap <HeroCard, HeroModel>();
        }
Пример #3
0
        public static CardSearchService AllowedDeckCardsFilterService(IHearthstoneCardCache cardCache, string selectedHeroClass)
        {
            FilterAllowedDeckCardsQuery filterAllowedDeckCardsQuery = new FilterAllowedDeckCardsQuery(selectedHeroClass);
            IEnumerable <ICard>         nonHeroCards     = cardCache.Query(filterAllowedDeckCardsQuery);
            HearthstoneCardCache        nonHeroCardCache = new HearthstoneCardCache(nonHeroCards);

            return(new CardSearchService(nonHeroCardCache));
        }
Пример #4
0
        public static CardSearchService DeckHeroFilterService(IHearthstoneCardCache cardCache, string type)
        {
            FilterHeroCardsQuery filterHeroCardsQuery = new FilterHeroCardsQuery(type);
            IEnumerable <ICard>  nonHeroCards         = cardCache.Query(filterHeroCardsQuery);
            HearthstoneCardCache nonHeroCardCache     = new HearthstoneCardCache(nonHeroCards);

            return(new CardSearchService(nonHeroCardCache));
        }
Пример #5
0
        public static CardSearchService DeckHeroSearchService(IHearthstoneCardCache cardCache)
        {
            SearchCardsQuery     findNonHeroCardsQuery = new SearchCardsQuery("");
            IEnumerable <ICard>  nonHeroCards          = cardCache.Query(findNonHeroCardsQuery);
            HearthstoneCardCache nonHeroCardCache      = new HearthstoneCardCache(nonHeroCards);

            return(new CardSearchService(nonHeroCardCache));
        }
Пример #6
0
        public static CardSearchService CardsFilterService(IHearthstoneCardCache cardCache, string playerClass)
        {
            FilterNonHeroCardsQuery filterNonHerCardsQuery = new FilterNonHeroCardsQuery(playerClass);
            IEnumerable <ICard>     nonHeroCards           = cardCache.Query(filterNonHerCardsQuery);
            HearthstoneCardCache    nonHeroCardCache       = new HearthstoneCardCache(nonHeroCards);

            return(new CardSearchService(nonHeroCardCache));
        }
Пример #7
0
        public HeroModel Resolve(ICard source, CardModel destination, HeroModel destMember, ResolutionContext context)
        {
            if (String.IsNullOrEmpty(source.PlayerClass))
            {
                return(null);
            }

            var heroCard = _repository.Query(new FindHeroCardQuery(source.PlayerClass));


            return(heroCard == null ? null : context.Mapper.Map <HeroCard, HeroModel>(heroCard));
        }
Пример #8
0
        protected override void Configure()
        {
            CreateMap <ICard, CardModel>()
            .Include <Card, CardModel>()
            .Include <MinionCard, MinionModel>()
            .Include <WeaponCard, WeaponModel>()
            .Include <SpellCard, SpellModel>()
            .Include <HeroCard, HeroModel>()
            .ForMember(m => m.PlayerClass,
                       opt => opt.ResolveUsing(m => _hearthstoneCardCache.Query(new FindHeroCardQuery(m.PlayerClass))))
            //opt => opt.ResolveUsing(i => i.PlayerClass))
            .ForMember(m => m.PlayerClassText, opt =>
            {
                opt.NullSubstitute("Neutral");
                opt.MapFrom(m => m.PlayerClass);
            })
            .ReverseMap()
            .ForMember(i => i.PlayerClass, opt =>
            {
                opt.MapFrom(m => m.PlayerClassText);
            })
            ;

            /*
             * CreateMap<CardModel, ICard>()
             *  .Include<CardModel, Card>()
             *  .Include<MinionModel, MinionCard>()
             *  .Include<WeaponModel, WeaponCard>()
             *  .Include<SpellModel, SpellCard>()
             *  .Include<HeroModel, HeroCard>()
             *  .ForMember(m => m.PlayerClass, opt =>
             *  {
             *      opt.NullSubstitute("Neutral");
             *      opt.MapFrom(m => m.PlayerClass);
             *  })
             *  ;*/

            CreateMap <Card, CardModel>();
            CreateMap <MinionCard, MinionModel>();
            CreateMap <WeaponCard, WeaponModel>();
            CreateMap <SpellCard, SpellModel>();
            CreateMap <HeroCard, HeroModel>();
        }
Пример #9
0
        public IEnumerable <CardModel> Search(string searchTerm)
        {
            var cards = _cardCache.Query(new SearchCardsQuery(searchTerm));

            return(Mapper.Map <IEnumerable <ICard>, IEnumerable <CardModel> >(cards));
        }