/// <summary>
        /// Processes the supplied <paramref name="queryResult"/> from the data source.
        /// </summary>
        /// <param name="resultHandlerContext"></param>
        /// <param name="processResult">The real result of the execution operation.</param>
        /// <exception cref="ArgumentNullException">The value of '<paramref name="resultHandlerContext"/>' cannot be null.</exception>
        /// <returns>A value indicating, whether, this handler handled the <paramref name="queryResult"/>.</returns>
        public Boolean TryProcessQueryResult(ResultHandlerContext resultHandlerContext, out Object processResult)
        {
            if (resultHandlerContext == null)
            {
                throw new ArgumentNullException(nameof(resultHandlerContext));
            }

            processResult = null;

            var instanceDescriptorQueryable = resultHandlerContext.Result as IQueryable <InstanceDescriptor>;

            if (instanceDescriptorQueryable != null)
            {
                var instances = instanceDescriptorQueryable.AsEnumerable() /*.AsParallel().AsOrdered()*/.Select(instanceDescriptor =>
                {
                    using (var instanceResolutionWalker = this.instanceResolutionWalkerFactory.CreateExport())
                    {
                        return(instanceResolutionWalker.Value.ResolveInstance(new InstanceResolutionContext(instanceDescriptor, resultHandlerContext.InstanceRelationStore)
                        {
                            NoChangeTracking = resultHandlerContext.NoChangeTracking,
                            NoLazyLoading = resultHandlerContext.NoLazyLoading
                        }));
                    }
                });

                processResult = instances.GetEnumerator();
            }

            return(instanceDescriptorQueryable != null);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Processes the supplied <paramref name="queryResult"/> from the data source.
        /// </summary>
        /// <param name="resultHandlerContext"></param>
        /// <param name="processResult">The real result of the execution operation.</param>
        /// <exception cref="ArgumentNullException">The value of '<paramref name="resultHandlerContext"/>' cannot be null.</exception>
        /// <returns>A value indicating, whether, this handler handled the <paramref name="queryResult"/>.</returns>
        public Boolean TryProcessQueryResult(ResultHandlerContext resultHandlerContext, out Object processResult)
        {
            if (resultHandlerContext == null)
            {
                throw new ArgumentNullException(nameof(resultHandlerContext));
            }

            processResult = null;

            var instanceDescriptor = resultHandlerContext.Result as InstanceDescriptor;

            if (instanceDescriptor != null)
            {
                using (var instanceResolutionWalker = this.instanceResolutionWalkerFactory.CreateExport())
                {
                    processResult = instanceResolutionWalker.Value.ResolveInstance(new InstanceResolutionContext(instanceDescriptor, resultHandlerContext.InstanceRelationStore)
                    {
                        NoChangeTracking = resultHandlerContext.NoChangeTracking,
                        NoLazyLoading    = resultHandlerContext.NoLazyLoading
                    });
                }
            }

            return(instanceDescriptor != null);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Processes the supplied <paramref name="queryResult"/> from the data source.
        /// </summary>
        /// <param name="resultHandlerContext"></param>
        /// <exception cref="ArgumentNullException">The value of '<paramref name="resultHandlerContext"/>' cannot be null.</exception>
        /// <returns>The real result of the query.</returns>
        public Object CreateResult(ResultHandlerContext resultHandlerContext)
        {
            if (resultHandlerContext == null)
            {
                throw new ArgumentNullException(nameof(resultHandlerContext));
            }

            Object result = null;

            foreach (var queryResultHandler in this.queryResultHandlers)
            {
                if (queryResultHandler.TryProcessQueryResult(resultHandlerContext, out result))
                {
                    break;
                }
            }

            return(result);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Processes the supplied <paramref name="queryResult"/> from the data source.
        /// </summary>
        /// <param name="resultHandlerContext"></param>
        /// <param name="processResult">The real result of the execution operation.</param>
        /// <exception cref="ArgumentNullException">The value of '<paramref name="resultHandlerContext"/>' cannot be null.</exception>
        /// <returns>A value indicating, whether, this handler handled the <paramref name="queryResult"/>.</returns>
        public Boolean TryProcessQueryResult(ResultHandlerContext resultHandlerContext, out Object processResult)
        {
            if (resultHandlerContext == null)
            {
                throw new ArgumentNullException(nameof(resultHandlerContext));
            }

            processResult = null;
            if (resultHandlerContext.Result == null)
            {
                return(false);
            }

            var queryResultClassification = resultHandlerContext.Result.GetType().Classify();

            if (queryResultClassification == TypeClassifier.TypeClassification.Primitive)
            {
                processResult = resultHandlerContext.Result;
            }

            return(queryResultClassification == TypeClassifier.TypeClassification.Primitive);
        }