/// <summary> /// Creates a new builder context by applying previously snapshotted parental context. /// </summary> /// <param name="builderContext">The current builder context.</param> /// <returns>The new builder context to be used for child processing.</returns> public HqlBuilderContext CreateParentingContext(HqlBuilderContext builderContext) { return(_next.CreateParentingContext(builderContext)); }
private TBuildResult ProcessDefinition( TBuildResult parentResult, TBuilderContext builderContext, CompositeDefinitionProcessorContext processorContext) { // Apply authorization for aggregate roots here if (processorContext.CurrentResourceClass.Entity.IsAggregateRoot) { // Provide opportunity to perform processing related to navigating into another resource (i.e. authorization) if (!_compositeBuilder.TryIncludeResource(processorContext, builderContext)) { return(default(TBuildResult)); } } bool isMainQuery = processorContext.IsBaseResource(); if (isMainQuery) { _compositeBuilder.ApplyRootResource(processorContext, builderContext); } else { _compositeBuilder.ApplyChildResource(builderContext, processorContext); } var nonIncomingIdentifyingProperties = processorContext.NonIncomingIdentifyingProperties(); ApplyLocalIdentifyingProperties(builderContext, processorContext, nonIncomingIdentifyingProperties); // Capture current applicable builder state so it can be modified further at this level without changes affecting children _compositeBuilder.SnapshotParentingContext(builderContext); // Select projected properties var propertyProjections = GetPropertyProjections(processorContext, processorContext.PropertyElements()); // Project the properties into the artifact under construction _compositeBuilder.ProjectProperties(propertyProjections, builderContext, processorContext); // Process flattened References ProcessFlattenedMemberProperties(processorContext, builderContext); TBuildResult thisBuildResult; if (isMainQuery) { // Short circuit the rest of the processing if the root result is null if (!_compositeBuilder.TryBuildForRootResource(builderContext, processorContext, out thisBuildResult)) { return(default(TBuildResult)); } } else { thisBuildResult = _compositeBuilder.BuildForChildResource( parentResult, builderContext, processorContext); } var childBuilderContext = _compositeBuilder.CreateParentingContext(builderContext); ProcessChildren(thisBuildResult, processorContext, childBuilderContext); if (_performValidation && _validationErrors.Any()) { throw new Exception(string.Join(Environment.NewLine, _validationErrors.ToArray())); } return(thisBuildResult); }