public IMapTask <T> Register <T>(string key = null) where T : class, new() { var type = typeof(T); if (_mapRegistry.Has(type)) { return(_mapRegistry[type] as IMapTask <T>); } var mapTask = _mapRegistry.Register <T>(); if (string.IsNullOrWhiteSpace(key)) { key = type.FullName; } _cacheRegistry.Add(async x => { var cache = x; var cmsQuery = _queryFactory.Create(cache.Site, mapTask); var contents = _cmsFetcher.Fetch(cmsQuery); var models = (await _mapper.ToAsync <T>(cache, contents).ConfigureAwait(false)).AsList(); return(models); }, key); return(mapTask); }
private IList <IMapItem> GetMaps(IMapTask mapTask) { var maps = new List <IMapItem>(); foreach (var map in mapTask.Maps) { if (map is MapItemCopy) { if (_registry.Has(map.ContentType)) { maps.AddRange(_registry[map.ContentType].Maps); } } else { maps.Add(map); } } return(maps); }