Ejemplo n.º 1
0
        public void Load(ILoadingContext loadingContext)
        {
            var lookupIds  = loadingContext.ReferenceIds <TReference, TId>();
            var references = _loadReferences(lookupIds);

            loadingContext.AddResults(references, reference => _getReferenceId(reference));
        }
Ejemplo n.º 2
0
        private void LoadTags(IReadOnlyList <object> referenceIds, ILoadingContext loadingContext)
        {
            var lookupIds  = referenceIds.OfType <int>();
            var references = lookupIds
                             .Select(id =>
                                     new Tag
            {
                Id   = id,
                Name = id + "-name"
            }
                                     )
                             .ToList();

            loadingContext.AddResults(
                references,
                reference => reference.Id
                );
        }
Ejemplo n.º 3
0
        private void LoadImages(ILoadingContext loadingContext)
        {
            var lookupIds  = loadingContext.ReferenceIds <Image, string>();
            var references = lookupIds
                             .Select(id =>
                                     new Image
            {
                Id      = id,
                Credits = id + "-credits",
                Url     = id + "-url"
            }
                                     )
                             .ToList();

            loadingContext.AddResults(
                references,
                reference => reference.Id
                );
        }
        public void Load(ILoadingContext loadingContext)
        {
            var lookupIds  = loadingContext.ReferenceIds <ImageWithRatios, string>();
            var repository = new ImageWithRatioRepository();
            var images     = repository.GetByDeclinaisonUrl(lookupIds);

            var imagesByDeclinaisonUrl = images.SelectMany(
                image => image.Ratios.Select(declinaison => new
            {
                DeclinaisonUrl = declinaison.Url,
                Image          = image
            })
                )
                                         .ToDictionary(
                imageByDeclinaisonUrl => imageByDeclinaisonUrl.DeclinaisonUrl,
                imageByDeclinaisonUrl => imageByDeclinaisonUrl.Image);

            loadingContext.AddResults(imagesByDeclinaisonUrl);
        }
Ejemplo n.º 5
0
        private void LoadMedia(IReadOnlyList <object> referenceIds, ILoadingContext loadingContext)
        {
            var lookupIds  = referenceIds.OfType <int>();
            var references = lookupIds.Select(id =>
                                              new Media {
                Id     = id,
                Title  = "title-" + id,
                TagIds = new List <int>
                {
                    1000 + id,
                    1001 + id
                }
            }
                                              )
                             .ToList();

            loadingContext.AddResults(
                references,
                reference => reference.Id
                );
        }
Ejemplo n.º 6
0
        private void LoadBlogPosts(ILoadingContext loadingContext)
        {
            var lookupIds  = loadingContext.ReferenceIds <BlogPost, int>();
            var references = lookupIds
                             .Select(id =>
                                     new BlogPost
            {
                Id     = id,
                Author = new Author
                {
                    Name    = "author-name-" + id,
                    Email   = "author-email-" + id,
                    ImageId = "id-" + (id + 500)
                },
                MultimediaContentRef = new MultimediaContentReference
                {
                    Type = id % 2 == 0
                                ? "image"
                                : "media",
                    Id = id % 2 == 0
                                ? "id-" + id
                                : (object)id
                },
                TagIds = new List <int>
                {
                    88 + id,
                    89 + id
                },
                Title = "Title-" + id
            }
                                     )
                             .ToList();

            loadingContext.AddResults(
                references,
                reference => reference.Id
                );
        }