Exemplo n.º 1
0
        /// <inheritdoc/>
        public void BeforeRead <TResource>(ResourcePipeline pipeline, string stringId = null) where TResource : class, IIdentifiable
        {
            var hookContainer = _executorHelper.GetResourceHookContainer <TResource>(ResourceHook.BeforeRead);

            hookContainer?.BeforeRead(pipeline, false, stringId);
            var calledContainers = new List <LeftType> {
                typeof(TResource)
            };

            foreach (var chain in _includeService.Get())
            {
                RecursiveBeforeRead(chain, pipeline, calledContainers);
            }
        }
Exemplo n.º 2
0
        /// <inheritdoc/>
        public virtual void BeforeRead <TEntity>(ResourcePipeline pipeline, string stringId = null) where TEntity : class, IIdentifiable
        {
            var hookContainer = _executorHelper.GetResourceHookContainer <TEntity>(ResourceHook.BeforeRead);

            hookContainer?.BeforeRead(pipeline, false, stringId);
            var contextEntity    = _graph.GetContextEntity(typeof(TEntity));
            var calledContainers = new List <PrincipalType>()
            {
                typeof(TEntity)
            };

            foreach (var relationshipPath in _context.IncludedRelationships)
            {
                RecursiveBeforeRead(contextEntity, relationshipPath.Split('.').ToList(), pipeline, calledContainers);
            }
        }
        /// <inheritdoc />
        public void BeforeRead <TResource>(ResourcePipeline pipeline, string stringId = null) where TResource : class, IIdentifiable
        {
            var hookContainer = _executorHelper.GetResourceHookContainer <TResource>(ResourceHook.BeforeRead);

            hookContainer?.BeforeRead(pipeline, false, stringId);
            var calledContainers = new List <LeftType> {
                typeof(TResource)
            };

            var includes = _constraintProviders
                           .SelectMany(p => p.GetConstraints())
                           .Select(expressionInScope => expressionInScope.Expression)
                           .OfType <IncludeExpression>()
                           .ToArray();

            foreach (var chain in includes.SelectMany(IncludeChainConverter.GetRelationshipChains))
            {
                RecursiveBeforeRead(chain.Fields.Cast <RelationshipAttribute>().ToList(), pipeline, calledContainers);
            }
        }
Exemplo n.º 4
0
        /// <inheritdoc />
        public void BeforeRead <TResource>(ResourcePipeline pipeline, string stringId = null) where TResource : class, IIdentifiable
        {
            var hookContainer = _executorHelper.GetResourceHookContainer <TResource>(ResourceHook.BeforeRead);

            hookContainer?.BeforeRead(pipeline, false, stringId);
            var calledContainers = typeof(TResource).AsList();

            // @formatter:wrap_chained_method_calls chop_always
            // @formatter:keep_existing_linebreaks true

            var includes = _constraintProviders
                           .SelectMany(provider => provider.GetConstraints())
                           .Select(expressionInScope => expressionInScope.Expression)
                           .OfType <IncludeExpression>()
                           .ToArray();

            // @formatter:keep_existing_linebreaks restore
            // @formatter:wrap_chained_method_calls restore

            foreach (var chain in includes.SelectMany(IncludeChainConverter.GetRelationshipChains))
            {
                RecursiveBeforeRead(chain.Fields.Cast <RelationshipAttribute>().ToList(), pipeline, calledContainers);
            }
        }