コード例 #1
0
        /// <summary>
        /// Enrich the list of resources.
        /// </summary>
        /// <typeparam name="TResource">The resource type to enrich.</typeparam>
        /// <param name="context">The enrichment context.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>A task which asynchronously performs the operation.</returns>
        async Task EnrichAsync <TResource>(EnrichmentContext <TResource> context, CancellationToken cancellationToken)
        {
            var relationship = (IRelationship)context.MemberPath.Member;

            var @delegate = GetOrCreateEnrichmentDelegate <TResource>(relationship);

            await @delegate(context, cancellationToken);
        }
コード例 #2
0
        /// <summary>
        /// Perform the enrichment for the given source and it's children.
        /// </summary>
        /// <typeparam name="TSource">The resource type to create the enricher for.</typeparam>
        /// <typeparam name="TDestination">The resource type on the other end of the relationship that is being enriched from.</typeparam>
        /// <param name="context">The enrichment context.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>A task which asynchronously performs the operation.</returns>
        async Task EnrichAsync <TSource, TDestination>(
            EnrichmentContext <TSource> context,
            CancellationToken cancellationToken)
        {
            var enricher = _resourceEnricherFactory.CreateEnricher <TSource, TDestination>((IRelationship)context.MemberPath.Member, context.Database);

            var destination = await enricher.EnrichAsync(context.Resources, cancellationToken);

            await EnrichAsync(context.Database, destination, context.MemberPath.Children, cancellationToken);
        }
コード例 #3
0
        /// <summary>
        /// Enrich the list of resources.
        /// </summary>
        /// <typeparam name="TResource">The resource type to enrich.</typeparam>
        /// <param name="database">The database to perform the enrichment within.</param>
        /// <param name="resources">The list of resources to enrich.</param>
        /// <param name="memberPaths">The list of member access paths that define what to enrich.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>A task which asynchronously performs the operation.</returns>
        public async Task EnrichAsync <TResource>(
            IDatabase database,
            IReadOnlyList <TResource> resources,
            IReadOnlyList <MemberPath> memberPaths,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            foreach (var memberPath in memberPaths.Where(m => m.Member is IRelationship))
            {
                var context = new EnrichmentContext <TResource>(database, resources, memberPath);

                await EnrichAsync(context, cancellationToken);
            }
        }